-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cli): ♻️ migrated cli to
clap
(#34)
* refactor(cli): ♻️ migrated cli to `clap` * fix(cli): 🐛 fixed cli cleaning and switched to `fmterr`
- Loading branch information
1 parent
53bb61e
commit 83e365c
Showing
9 changed files
with
151 additions
and
141 deletions.
There are no files selected for viewing
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#![allow(missing_docs)] // Prevents double-documenting some things | ||
|
||
use crate::PERSEUS_VERSION; | ||
use clap::{AppSettings, Clap}; | ||
|
||
// The documentation for the `Opts` struct will appear in the help page, hence the lack of puncutation and the lowercasing in places | ||
|
||
/// The command-line interface for Perseus, a super-fast WebAssembly frontend development framework! | ||
#[derive(Clap)] | ||
#[clap(version = PERSEUS_VERSION)] | ||
#[clap(setting = AppSettings::ColoredHelp)] | ||
pub struct Opts { | ||
#[clap(subcommand)] | ||
pub subcmd: Subcommand, | ||
} | ||
|
||
#[derive(Clap)] | ||
pub enum Subcommand { | ||
Build(BuildOpts), | ||
Export(ExportOpts), | ||
Serve(ServeOpts), | ||
/// Serves your app as `perseus serve` does, but puts it in testing mode | ||
Test(ServeOpts), | ||
Clean(CleanOpts), | ||
/// Ejects you from the CLI harness, enabling you to work with the internals of Perseus | ||
Eject, | ||
/// Prepares the `.perseus/` directory (done automatically by `build` and `serve`) | ||
Prep, | ||
} | ||
/// Builds your app | ||
#[derive(Clap)] | ||
pub struct BuildOpts { | ||
/// Build for production | ||
#[clap(long)] | ||
release: bool, | ||
} | ||
/// Exports your app to purely static files | ||
#[derive(Clap)] | ||
pub struct ExportOpts { | ||
/// Export for production | ||
#[clap(long)] | ||
release: bool, | ||
} | ||
/// Serves your app (set the `$HOST` and `$PORT` environment variables to change the location it's served at) | ||
#[derive(Clap)] | ||
pub struct ServeOpts { | ||
/// Don't run the final binary, but print its location instead as the last line of output | ||
#[clap(long)] | ||
pub no_run: bool, | ||
/// Only build the server, and use the results of a previous `perseus build` | ||
#[clap(long)] | ||
pub no_build: bool, | ||
/// Build and serve for production | ||
#[clap(long)] | ||
release: bool, | ||
} | ||
/// Removes `.perseus/` entirely for updates or to fix corruptions | ||
#[derive(Clap)] | ||
pub struct CleanOpts { | ||
/// Only remove the `.perseus/dist/` folder (use if you've ejected) | ||
#[clap(short, long)] | ||
pub dist: bool, | ||
/// Remove the directory, even if you've ejected (this will permanently destroy any changes you've made to `.perseus/`!) | ||
#[clap(short, long)] | ||
pub force: bool, | ||
} |
Oops, something went wrong.