mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 22:31:35 +03:00
feat: deprecate --cwd
in favor of the positional argument (#100)
This commit is contained in:
parent
ffc9160244
commit
e8b65089d3
@ -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()),
|
||||
|
Loading…
Reference in New Issue
Block a user