-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from dherman/rename-more-commands
Changes to command UX
- Loading branch information
Showing
13 changed files
with
143 additions
and
209 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ impl EventsConfig { | |
Some(p.into_publish()?) | ||
} else { | ||
None | ||
} | ||
}, | ||
}) | ||
} | ||
} | ||
|
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
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,78 @@ | ||
use semver::VersionReq; | ||
|
||
use notion_core::serial::version::parse_requirements; | ||
use notion_core::session::{ActivityKind, Session}; | ||
use notion_fail::Fallible; | ||
|
||
use Notion; | ||
use command::{Command, CommandName, Help}; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub(crate) struct Args { | ||
arg_package: String, | ||
arg_version: String, | ||
} | ||
|
||
pub(crate) enum Install { | ||
Help, | ||
Node(VersionReq), | ||
Yarn(VersionReq), | ||
Other { name: String, version: VersionReq }, | ||
} | ||
|
||
impl Command for Install { | ||
type Args = Args; | ||
|
||
const USAGE: &'static str = " | ||
Install a global package | ||
Usage: | ||
notion install <package> <version> | ||
notion install -h | --help | ||
Options: | ||
-h, --help Display this message | ||
"; | ||
|
||
fn help() -> Self { | ||
Install::Help | ||
} | ||
|
||
fn parse( | ||
_: Notion, | ||
Args { | ||
arg_package, | ||
arg_version, | ||
}: Args, | ||
) -> Fallible<Self> { | ||
match &arg_package[..] { | ||
"node" => Ok(Install::Node(parse_requirements(&arg_version)?)), | ||
"yarn" => Ok(Install::Yarn(parse_requirements(&arg_version)?)), | ||
ref package => Ok(Install::Other { | ||
name: package.to_string(), | ||
version: parse_requirements(&arg_version)?, | ||
}), | ||
} | ||
} | ||
|
||
fn run(self, session: &mut Session) -> Fallible<bool> { | ||
session.add_event_start(ActivityKind::Install); | ||
match self { | ||
Install::Help => { | ||
Help::Command(CommandName::Install).run(session)?; | ||
} | ||
Install::Node(requirements) => { | ||
session.set_default_node(&requirements)?; | ||
} | ||
Install::Yarn(requirements) => { | ||
session.set_default_yarn(&requirements)?; | ||
} | ||
Install::Other { | ||
name: _, | ||
version: _, | ||
} => unimplemented!(), | ||
}; | ||
session.add_event_end(ActivityKind::Install, 0); | ||
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
Oops, something went wrong.