mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: deprecate --cwd in favor of the positional argument (#100)
This commit is contained in:
parent
ffc9160244
commit
e8b65089d3
1 changed files with 17 additions and 2 deletions
|
|
@ -18,8 +18,13 @@ pub struct Boot {
|
||||||
#[command(name = "yazi")]
|
#[command(name = "yazi")]
|
||||||
#[command(version = "0.1.3")]
|
#[command(version = "0.1.3")]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
// -- TODO: Deprecate this in v0.1.5
|
||||||
/// Set the current working directory
|
/// Set the current working directory
|
||||||
#[arg(long, short)]
|
#[arg(long, short)]
|
||||||
|
_cwd: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// Set the current working directory
|
||||||
|
#[arg(index = 1)]
|
||||||
cwd: Option<PathBuf>,
|
cwd: Option<PathBuf>,
|
||||||
|
|
||||||
/// Write the cwd on exit to this file
|
/// Write the cwd on exit to this file
|
||||||
|
|
@ -38,8 +43,18 @@ impl Default for Boot {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let cwd =
|
// -- TODO: Deprecate this in v0.1.5
|
||||||
args.cwd.map(absolute_path).filter(|p| p.is_dir()).or_else(|| env::current_dir().ok());
|
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 {
|
let boot = Self {
|
||||||
cwd: cwd.unwrap_or("/".into()),
|
cwd: cwd.unwrap_or("/".into()),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue