-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fastn-cli/code-cleanup: publish-static code cleanup
- Loading branch information
Showing
6 changed files
with
91 additions
and
270 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
pub(crate) const PUBLISH_STATIC: &str = "publish-static"; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error("PublishStaticError: {}", _0)] | ||
PublishStaticError(#[from] PublishStaticError), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum PublishStaticError { | ||
#[error("PublishStaticUploadError: {}", _0)] | ||
Upload(#[from] fastn_cloud::UploadError), | ||
} | ||
|
||
pub(crate) async fn handle() -> Result<bool, Error> { | ||
Ok(handle_publish_static().await?) | ||
} | ||
|
||
pub(crate) async fn handle_publish_static() -> Result<bool, PublishStaticError> { | ||
fastn_cloud::upload().await?; | ||
Ok(true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1 @@ | ||
pub(crate) mod cloud; | ||
pub(crate) const PUBLISH_STATIC: &str = "publish-static"; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error("PublishStaticError: {}", _0)] | ||
PublishStaticError(#[from] PublishStaticError), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum PublishStaticError { | ||
#[error("PublishStaticCreateError: {}", _0)] | ||
Create(#[from] fastn_cloud::CreateError), | ||
#[error("PublishStaticUpdateError: {}", _0)] | ||
Update(#[from] fastn_cloud::UpdateError), | ||
#[error("PublishStaticUploadError: {}", _0)] | ||
Upload(#[from] fastn_cloud::UploadError), | ||
} | ||
|
||
pub(crate) async fn handle(matches: &clap::ArgMatches) -> Result<bool, Error> { | ||
// TODO: Handle Dynamic Commands | ||
Ok(handle_publish_static(matches).await?) | ||
} | ||
|
||
pub(crate) async fn handle_publish_static( | ||
matches: &clap::ArgMatches, | ||
) -> Result<bool, PublishStaticError> { | ||
match matches.subcommand() { | ||
Some(("create", _matches)) => { | ||
fastn_cloud::create().await?; | ||
Ok(true) | ||
} | ||
Some(("update", _matches)) => { | ||
fastn_cloud::update().await?; | ||
Ok(true) | ||
} | ||
Some(("upload", _matches)) => { | ||
fastn_cloud::upload().await?; | ||
Ok(true) | ||
} | ||
_ => Ok(false), | ||
} | ||
} |
Oops, something went wrong.