forked from prefix-dev/pixi
-
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.
feat: add get and set name commands to project (prefix-dev#2649)
Co-authored-by: Ruben Arts <[email protected]>
- Loading branch information
1 parent
da38075
commit 6da07e2
Showing
8 changed files
with
114 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::Project; | ||
|
||
pub async fn execute(project: Project) -> miette::Result<()> { | ||
println!("{}", project.name()); | ||
Ok(()) | ||
} |
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,36 @@ | ||
pub mod get; | ||
pub mod set; | ||
|
||
use crate::cli::cli_config::ProjectConfig; | ||
use crate::Project; | ||
use clap::Parser; | ||
|
||
/// Commands to manage project name. | ||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
#[clap(flatten)] | ||
pub project_config: ProjectConfig, | ||
|
||
/// The subcommand to execute | ||
#[clap(subcommand)] | ||
pub command: Command, | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub enum Command { | ||
/// Get the project name. | ||
Get, | ||
/// Set the project name | ||
Set(set::Args), | ||
} | ||
|
||
pub async fn execute(args: Args) -> miette::Result<()> { | ||
let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?; | ||
|
||
match args.command { | ||
Command::Get => get::execute(project).await?, | ||
Command::Set(args) => set::execute(project, args).await?, | ||
} | ||
|
||
Ok(()) | ||
} |
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,26 @@ | ||
use crate::Project; | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
/// The project name | ||
#[clap(required = true, num_args = 1)] | ||
pub name: String, | ||
} | ||
|
||
pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> { | ||
// Set the new project name | ||
project.manifest.set_name(&args.name)?; | ||
|
||
// Save project | ||
project.save()?; | ||
|
||
// Report back to the user | ||
eprintln!( | ||
"{}Updated project name to '{}'.", | ||
console::style(console::Emoji("✔ ", "")).green(), | ||
project.manifest.workspace.workspace.name | ||
); | ||
|
||
Ok(()) | ||
} |
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