Add 'packages upgrade' command.
This commit is contained in:
parent
6286132a3e
commit
219e81cb75
|
@ -17,10 +17,13 @@ pub struct Args {
|
||||||
///
|
///
|
||||||
/// Note that by default, this assumes the package is located
|
/// Note that by default, this assumes the package is located
|
||||||
/// on Github.
|
/// on Github.
|
||||||
package: String,
|
pub package: String,
|
||||||
/// The package version, as a git commit hash, a tag or a branch name.
|
/// The package version, as a git commit hash, a tag or a branch name.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
version: String,
|
pub version: String,
|
||||||
|
|
||||||
|
#[clap(hide = true)]
|
||||||
|
pub overwrite: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(args: Args) -> miette::Result<()> {
|
pub fn exec(args: Args) -> miette::Result<()> {
|
||||||
|
@ -42,18 +45,22 @@ pub fn exec(args: Args) -> miette::Result<()> {
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
pretty::pad_left("Adding".to_string(), 13, " ")
|
pretty::pad_left("Package".to_string(), 13, " ")
|
||||||
.bold()
|
.bold()
|
||||||
.purple(),
|
.purple(),
|
||||||
dependency.name.bright_blue(),
|
dependency.name.bright_blue(),
|
||||||
);
|
);
|
||||||
|
|
||||||
match config.insert(&dependency, false) {
|
match config.insert(&dependency, args.overwrite) {
|
||||||
Some(config) => {
|
Some(config) => {
|
||||||
config.save(&root).into_diagnostic()?;
|
config.save(&root).into_diagnostic()?;
|
||||||
println!(
|
println!(
|
||||||
"{} version = {}",
|
"{} version → {}",
|
||||||
pretty::pad_left("Added".to_string(), 13, " ")
|
pretty::pad_left(
|
||||||
|
if args.overwrite { "Changed" } else { "Added" }.to_string(),
|
||||||
|
13,
|
||||||
|
" "
|
||||||
|
)
|
||||||
.bold()
|
.bold()
|
||||||
.purple(),
|
.purple(),
|
||||||
dependency.version.yellow()
|
dependency.version.yellow()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod add;
|
pub mod add;
|
||||||
pub mod clear_cache;
|
pub mod clear_cache;
|
||||||
|
pub mod upgrade;
|
||||||
|
|
||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
|
|
||||||
|
@ -10,6 +11,9 @@ pub enum Cmd {
|
||||||
/// Add a new package dependency
|
/// Add a new package dependency
|
||||||
Add(add::Args),
|
Add(add::Args),
|
||||||
|
|
||||||
|
/// Change the version of an installed dependency
|
||||||
|
Upgrade(upgrade::Args),
|
||||||
|
|
||||||
/// Clear the system-wide dependencies cache
|
/// Clear the system-wide dependencies cache
|
||||||
ClearCache,
|
ClearCache,
|
||||||
}
|
}
|
||||||
|
@ -18,5 +22,6 @@ pub fn exec(cmd: Cmd) -> miette::Result<()> {
|
||||||
match cmd {
|
match cmd {
|
||||||
Cmd::Add(args) => add::exec(args),
|
Cmd::Add(args) => add::exec(args),
|
||||||
Cmd::ClearCache => clear_cache::exec(),
|
Cmd::ClearCache => clear_cache::exec(),
|
||||||
|
Cmd::Upgrade(args) => upgrade::exec(args),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
use super::add;
|
||||||
|
|
||||||
|
#[derive(clap::Args)]
|
||||||
|
/// Change the version of an installed dependency
|
||||||
|
pub struct Args {
|
||||||
|
/// Package name, in the form of {owner}/{repository}.
|
||||||
|
///
|
||||||
|
/// For example → 'add aiken-lang/stdlib'
|
||||||
|
///
|
||||||
|
/// Note that by default, this assumes the package is located
|
||||||
|
/// on Github.
|
||||||
|
package: String,
|
||||||
|
/// The package version, as a git commit hash, a tag or a branch name.
|
||||||
|
#[clap(long)]
|
||||||
|
version: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn exec(args: Args) -> miette::Result<()> {
|
||||||
|
add::exec(add::Args {
|
||||||
|
package: args.package,
|
||||||
|
version: args.version,
|
||||||
|
overwrite: true,
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue