Skip to content

Commit

Permalink
refactor(cli)!: Rename 'path' argument to 'project'
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 16, 2024
1 parent 54787eb commit 190a3c9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions assets/en-US/cli.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ help-subcommand-setup =
Setup a publishing project for use with CaSILE
# Currently hard coded, see clap issue #1880
help-subcommand-setup-path =
help-subcommand-setup-project =
Path to publishing project repository
error-not-setup =
Expand All @@ -58,7 +58,7 @@ error-invalid-resources =
error-no-remote =
Git repository does not have a working remote named 'origin'.
error-no-path =
error-no-project =
Cannot parse directory path.
welcome =
Expand Down
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub struct Cli {
#[clap(short, long)]
pub language: Option<String>,

// FTL: help-flag-path
// FTL: help-flag-project
/// Set project root path
#[clap(short, long, default_value = "./")]
pub path: path::PathBuf,
#[clap(short = 'P', long, default_value = "./")]
pub project: path::PathBuf,

// FTL: help-flag-quiet
/// Discard all non-error output messages
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl CONF {
.set_default("quiet", false)?
.set_default("verbose", false)?
.set_default("language", crate::DEFAULT_LOCALE)?
.set_default("path", "./")?;
.set_default("project", "./")?;
Ok(())
}

Expand Down Expand Up @@ -60,8 +60,8 @@ impl CONF {
} else if args.quiet {
self.set_bool("quiet", true)?;
}
if let Some(path) = &args.path.to_str() {
self.set_str("path", path)?;
if let Some(path) = &args.project.to_str() {
self.set_str("project", path)?;
}
if let Some(language) = &args.language {
self.set_str("language", language)?;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl error::Error for Error {

/// Get repository object
pub fn get_repo() -> Result<Repository> {
let path = CONF.get_string("path")?;
Ok(Repository::discover(path)?)
let project = CONF.get_string("project")?;
Ok(Repository::discover(project)?)
}

/// Check to see if we're running in GitHub Actions
Expand Down
2 changes: 1 addition & 1 deletion src/make/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn run(target: Vec<String>) -> Result<()> {
.env("CONTAINERIZED", status::is_container().to_string())
.env("LANGUAGE", locale_to_language(CONF.get_string("language")?))
.env("PROJECT", gitname)
.env("PROJECTDIR", CONF.get_string("path")?)
.env("PROJECTDIR", CONF.get_string("project")?)
.env("PROJECTVERSION", git_version);
if CONF.get_bool("debug")? {
// || targets.contains(&"-p".into())
Expand Down
2 changes: 1 addition & 1 deletion src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn run(name: String, arguments: Vec<OsString>) -> Result<()> {
.env("CONTAINERIZED", status::is_container().to_string())
.env("LANGUAGE", locale_to_language(CONF.get_string("language")?))
.env("PROJECT", gitname)
.env("PROJECTDIR", CONF.get_string("path")?)
.env("PROJECTDIR", CONF.get_string("project")?)
.env("PROJECTVERSION", git_version);
let repo = get_repo()?;
let workdir = repo.workdir().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use subprocess::{Exec, NullFile, Redirection};
/// Setup a publishing project for use with CaSILE
pub fn run() -> Result<()> {
let subcommand_status = CASILEUI.new_subcommand("setup");
let path = &CONF.get_string("path")?;
let metadata = fs::metadata(path)?;
let project = &CONF.get_string("project")?;
let metadata = fs::metadata(project)?;
let ret = match metadata.is_dir() {
true => match is_repo()? {
true => {
Expand Down
10 changes: 5 additions & 5 deletions src/status/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ pub fn get_gitname() -> Result<String> {
.as_str();
Ok(String::from(name))
}
fn path() -> Result<String> {
let path = &CONF.get_string("path")?;
let file = path::Path::new(path)
fn project() -> Result<String> {
let project = &CONF.get_string("project")?;
let file = path::Path::new(project)
.file_name()
.ok_or_else(|| Error::new("error-no-path"))?
.ok_or_else(|| Error::new("error-no-project"))?
.to_str();
Ok(file.unwrap().to_string())
}
let default = Ok(String::from("casile"));
origin().or_else(|_| path().or(default))
origin().or_else(|_| project().or(default))
}

/// Scan for existing makefiles with CaSILE rules
Expand Down

0 comments on commit 190a3c9

Please sign in to comment.