Add --add/--new to control CLI behaviour (#9202)
When neither is specified, if you open a directory you get a new workspace, otherwise files are added to your existing workspace. With --new files are always opened in a new workspace With --add directories are always added to an existing workspace Fixes #9076 Fixes #4861 Fixes #5370 Release Notes: - Added `-n/--new` and `-a/--add` to the zed CLI. When neither is specified, if you open a directory you get a new workspace, otherwise files are added to your existing workspace. With `--new` files are always opened in a new workspace, with `--add` directories are always added to an existing workspace. ([#9076](https://github.com/zed-industries/zed/issues/9096), [#4861](https://github.com/zed-industries/zed/issues/4861), [#5370](https://github.com/zed-industries/zed/issues/5370)).
This commit is contained in:
parent
89c67fb1ab
commit
05dfe96f0c
9 changed files with 369 additions and 103 deletions
|
@ -12,12 +12,18 @@ use std::{
|
|||
};
|
||||
use util::paths::PathLikeWithPosition;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
|
||||
struct Args {
|
||||
/// Wait for all of the given paths to be opened/closed before exiting.
|
||||
#[clap(short, long)]
|
||||
wait: bool,
|
||||
/// Add files to the currently open workspace
|
||||
#[clap(short, long, overrides_with = "new")]
|
||||
add: bool,
|
||||
/// Create a new workspace
|
||||
#[clap(short, long, overrides_with = "add")]
|
||||
new: bool,
|
||||
/// A sequence of space-separated paths that you want to open.
|
||||
///
|
||||
/// Use `path:line:row` syntax to open a file at a specific location.
|
||||
|
@ -67,6 +73,13 @@ fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
let (tx, rx) = bundle.launch()?;
|
||||
let open_new_workspace = if args.new {
|
||||
Some(true)
|
||||
} else if args.add {
|
||||
Some(false)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
tx.send(CliRequest::Open {
|
||||
paths: args
|
||||
|
@ -81,6 +94,7 @@ fn main() -> Result<()> {
|
|||
})
|
||||
.collect::<Result<_>>()?,
|
||||
wait: args.wait,
|
||||
open_new_workspace,
|
||||
})?;
|
||||
|
||||
while let Ok(response) = rx.recv() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue