-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
155 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,18 @@ use crate::config::{AppName, Version}; | |
/// a request from the user to run a particular app | ||
#[derive(Debug, PartialEq)] | ||
pub struct AppVersion { | ||
pub app: AppName, | ||
pub app_name: AppName, | ||
pub version: Option<Version>, | ||
} | ||
|
||
impl AppVersion { | ||
pub fn new<S: AsRef<str>>(token: S) -> Self { | ||
let (app_name, version) = token.as_ref().split_once('@').unwrap_or((token.as_ref(), "")); | ||
let version = if version.is_empty() { None } else { Some(Version::from(version)) }; | ||
AppVersion { app: app_name.into(), version } | ||
AppVersion { | ||
app_name: app_name.into(), | ||
version, | ||
} | ||
} | ||
} | ||
|
||
|
@@ -26,7 +29,7 @@ mod tests { | |
let give = "[email protected]"; | ||
let have = AppVersion::new(give); | ||
let want = AppVersion { | ||
app: AppName::from("shellcheck"), | ||
app_name: AppName::from("shellcheck"), | ||
version: Some(Version::from("0.9.0")), | ||
}; | ||
pretty::assert_eq!(have, want); | ||
|
@@ -37,7 +40,7 @@ mod tests { | |
let give = "shellcheck"; | ||
let have = AppVersion::new(give); | ||
let want = AppVersion { | ||
app: AppName::from("shellcheck"), | ||
app_name: AppName::from("shellcheck"), | ||
version: None, | ||
}; | ||
pretty::assert_eq!(have, want); | ||
|
@@ -48,7 +51,7 @@ mod tests { | |
let give = "shellcheck@"; | ||
let have = AppVersion::new(give); | ||
let want = AppVersion { | ||
app: AppName::from("shellcheck"), | ||
app_name: AppName::from("shellcheck"), | ||
version: None, | ||
}; | ||
pretty::assert_eq!(have, want); | ||
|
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,18 +1,17 @@ | ||
use crate::cmd::run; | ||
use crate::config::{AppName, Version}; | ||
use crate::cmd::{self, available, run, test, update, versions}; | ||
|
||
/// the main commands that run-this-app can execute | ||
#[derive(Debug, PartialEq)] | ||
pub enum Command { | ||
AppsLong, | ||
AppsShort, | ||
Available { app: AppName, version: Option<Version>, verbose: bool }, | ||
Available(available::Args), | ||
RunApp(run::Args), | ||
DisplayHelp, | ||
Setup, | ||
Test { app: Option<AppName>, verbose: bool }, | ||
Which { app: AppName, version: Option<Version>, verbose: bool }, | ||
Update { verbose: bool }, | ||
Test(test::Args), | ||
Which(cmd::which::Args), | ||
Update(update::Args), | ||
Version, | ||
Versions { app: AppName, amount: usize, verbose: bool }, | ||
Versions(versions::Args), | ||
} |
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.