mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Create files passed as args to CLI
Co-Authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
c85ad96b45
commit
d30e129d63
1 changed files with 20 additions and 1 deletions
|
@ -9,7 +9,13 @@ use core_foundation::{
|
||||||
use core_services::{kLSLaunchDefaults, LSLaunchURLSpec, LSOpenFromURLSpec, TCFType};
|
use core_services::{kLSLaunchDefaults, LSLaunchURLSpec, LSOpenFromURLSpec, TCFType};
|
||||||
use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{ffi::OsStr, fs, path::PathBuf, ptr};
|
use std::{
|
||||||
|
ffi::OsStr,
|
||||||
|
fs::{self, OpenOptions},
|
||||||
|
io,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
ptr,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
|
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
|
||||||
|
@ -54,6 +60,12 @@ fn main() -> Result<()> {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for path in args.paths.iter() {
|
||||||
|
if !path.exists() {
|
||||||
|
touch(path.as_path())?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (tx, rx) = launch_app(bundle_path)?;
|
let (tx, rx) = launch_app(bundle_path)?;
|
||||||
|
|
||||||
tx.send(CliRequest::Open {
|
tx.send(CliRequest::Open {
|
||||||
|
@ -77,6 +89,13 @@ fn main() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn touch(path: &Path) -> io::Result<()> {
|
||||||
|
match OpenOptions::new().create(true).write(true).open(path) {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn locate_bundle() -> Result<PathBuf> {
|
fn locate_bundle() -> Result<PathBuf> {
|
||||||
let cli_path = std::env::current_exe()?.canonicalize()?;
|
let cli_path = std::env::current_exe()?.canonicalize()?;
|
||||||
let mut app_path = cli_path.clone();
|
let mut app_path = cli_path.clone();
|
||||||
|
|
Loading…
Reference in a new issue