Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11302727
command.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
command.rs
View Options
// -------------------------------------------------------------
// Alkane :: Commands
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Project: Nasqueron
// License: BSD-2-Clause
// -------------------------------------------------------------
use
clap
::
{
Args
,
Parser
};
// -------------------------------------------------------------
// Main command
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[derive(Debug, Parser)]
#[command(name =
"alkane"
)]
#[clap(author=
"Nasqueron project"
, version, about=
"Manage Alkane PaaS"
, long_about=None)]
pub
enum
AlkaneCommand
{
/// Launch an HTTP server to expose the Alkane REST API
Server
(
ServerArgs
),
/// Initialize a site
#[command(arg_required_else_help = true)]
Init
(
DeployArgs
),
/// Update site assets to latest version
#[command(arg_required_else_help = true)]
Update
(
DeployArgs
),
/// Initialize of if already initialized update a site
#[command(arg_required_else_help = true)]
Deploy
(
DeployArgs
),
/// Determine if a domain is served on our PaaS
#[command(name =
"is-present"
, arg_required_else_help = true)]
IsPresent
(
IsPresentArgs
),
}
// -------------------------------------------------------------
// Subcommands arguments
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[derive(Debug, Args)]
pub
struct
ServerArgs
{
#[arg(long, default_value =
"/"
)]
pub
mounting_point
:
String
,
}
#[derive(Debug, Args)]
pub
struct
DeployArgs
{
/// The name of the site to deploy, using sub.domain.tld format
pub
site_name
:
String
,
/// The artifact to deploy. Allows CD to give metadata or an URL to download last artifact
pub
artifact
:
Option
<
String
>
,
}
#[derive(Debug, Args)]
pub
struct
IsPresentArgs
{
#[arg(short, long, default_value_t = false)]
pub
quiet
:
bool
,
/// The name of the site to deploy, using sub.domain.tld format
pub
site_name
:
String
,
}
// -------------------------------------------------------------
// Helper methods
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pub
trait
ToStatusCode
{
fn
to_status_code
(
&
self
)
->
i32
;
}
impl
ToStatusCode
for
bool
{
fn
to_status_code
(
&
self
)
->
i32
{
if
*
self
{
0
}
else
{
1
}
}
}
impl
<
T
>
ToStatusCode
for
Option
<
T
>
{
fn
to_status_code
(
&
self
)
->
i32
{
self
.
is_some
().
to_status_code
()
}
}
impl
<
T
,
E
>
ToStatusCode
for
Result
<
T
,
E
>
{
fn
to_status_code
(
&
self
)
->
i32
{
self
.
is_ok
().
to_status_code
()
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 24, 05:12 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2899492
Default Alt Text
command.rs (2 KB)
Attached To
Mode
rALK Alkane
Attached
Detach File
Event Timeline
Log In to Comment