feat: deprecate --cwd in favor of the positional argument (#100)

This commit is contained in:
三咲雅 · Misaki Masa 2023-09-01 13:42:31 +08:00 committed by GitHub
parent ffc9160244
commit e8b65089d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,8 +18,13 @@ pub struct Boot {
#[command(name = "yazi")]
#[command(version = "0.1.3")]
struct Args {
// -- TODO: Deprecate this in v0.1.5
/// Set the current working directory
#[arg(long, short)]
_cwd: Option<PathBuf>,
/// Set the current working directory
#[arg(index = 1)]
cwd: Option<PathBuf>,
/// Write the cwd on exit to this file
@ -38,8 +43,18 @@ impl Default for Boot {
fn default() -> Self {
let args = Args::parse();
let cwd =
args.cwd.map(absolute_path).filter(|p| p.is_dir()).or_else(|| env::current_dir().ok());
// -- TODO: Deprecate this in v0.1.5
let cwd = if args._cwd.is_some() {
println!(
"Warning: -c/--cwd is deprecated in v0.1.5, please use the positional argument instead: `yazi --cwd /path/to/dir` -> `yazi /path/to/dir`.\nSee https://github.com/sxyazi/yazi/issues/95 for more information."
);
args._cwd
} else {
args.cwd
};
// TODO: Deprecate this in v0.1.5 --
let cwd = cwd.map(absolute_path).filter(|p| p.is_dir()).or_else(|| env::current_dir().ok());
let boot = Self {
cwd: cwd.unwrap_or("/".into()),