Add layout-dir to setup --check subcommand
This commit is contained in:
parent
51c826b991
commit
6bcd84f6d5
2 changed files with 20 additions and 12 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -12,9 +12,7 @@ use zellij_server::{os_input_output::get_server_os_input, start_server};
|
|||
use zellij_utils::{
|
||||
cli::{CliArgs, Command, Sessions},
|
||||
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
|
||||
input::config::Config,
|
||||
input::layout::Layout,
|
||||
input::options::Options,
|
||||
input::{config::Config, layout::Layout, options::Options},
|
||||
logging::*,
|
||||
setup::{find_default_config_dir, get_default_data_dir, get_layout_dir, Setup},
|
||||
structopt::StructOpt,
|
||||
|
|
@ -25,8 +23,6 @@ pub fn main() {
|
|||
|
||||
if let Some(Command::Sessions(Sessions::ListSessions)) = opts.command {
|
||||
list_sessions();
|
||||
} else if let Some(Command::Setup(ref setup)) = opts.command {
|
||||
Setup::from_cli(setup, &opts).expect("Failed to print to stdout");
|
||||
}
|
||||
|
||||
let config = match Config::try_from(&opts) {
|
||||
|
|
@ -38,6 +34,10 @@ pub fn main() {
|
|||
};
|
||||
let config_options = Options::from_cli(&config.options, opts.command.clone());
|
||||
|
||||
if let Some(Command::Setup(ref setup)) = opts.command {
|
||||
Setup::from_cli(setup, &opts, &config_options).expect("Failed to print to stdout");
|
||||
}
|
||||
|
||||
atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
|
||||
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
|
||||
if let Some(path) = opts.server {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ use crate::cli::CliArgs;
|
|||
use crate::consts::{
|
||||
FEATURES, SYSTEM_DEFAULT_CONFIG_DIR, SYSTEM_DEFAULT_DATA_DIR_PREFIX, VERSION, ZELLIJ_PROJ_DIR,
|
||||
};
|
||||
use crate::input::options::Options;
|
||||
use directories_next::BaseDirs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::Write;
|
||||
use std::{path::Path, path::PathBuf};
|
||||
use std::{io::Write, path::Path, path::PathBuf};
|
||||
use structopt::StructOpt;
|
||||
|
||||
const CONFIG_LOCATION: &str = ".config/zellij";
|
||||
|
|
@ -117,13 +117,14 @@ pub struct Setup {
|
|||
#[structopt(long)]
|
||||
pub check: bool,
|
||||
|
||||
/// Generates completion for the specified shell
|
||||
#[structopt(long)]
|
||||
pub generate_completion: Option<String>,
|
||||
}
|
||||
|
||||
impl Setup {
|
||||
/// Entrypoint from main
|
||||
pub fn from_cli(&self, opts: &CliArgs) -> std::io::Result<()> {
|
||||
pub fn from_cli(&self, opts: &CliArgs, config_options: &Options) -> std::io::Result<()> {
|
||||
if self.clean {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -134,7 +135,7 @@ impl Setup {
|
|||
}
|
||||
|
||||
if self.check {
|
||||
Setup::check_defaults_config(opts)?;
|
||||
Setup::check_defaults_config(opts, config_options)?;
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -146,11 +147,14 @@ impl Setup {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_defaults_config(opts: &CliArgs) -> std::io::Result<()> {
|
||||
pub fn check_defaults_config(opts: &CliArgs, config_options: &Options) -> std::io::Result<()> {
|
||||
let data_dir = opts.data_dir.clone().unwrap_or_else(get_default_data_dir);
|
||||
let config_dir = opts.config_dir.clone().or_else(find_default_config_dir);
|
||||
let plugin_dir = data_dir.join("plugins");
|
||||
let layout_dir = data_dir.join("layouts");
|
||||
let layout_dir = config_options
|
||||
.layout_dir
|
||||
.clone()
|
||||
.or_else(|| get_layout_dir(config_dir.clone()));
|
||||
let system_data_dir = PathBuf::from(SYSTEM_DEFAULT_DATA_DIR_PREFIX).join("share/zellij");
|
||||
let config_file = opts
|
||||
.config
|
||||
|
|
@ -192,7 +196,11 @@ impl Setup {
|
|||
}
|
||||
message.push_str(&format!("[DATA DIR]: {:?}\n", data_dir));
|
||||
message.push_str(&format!("[PLUGIN DIR]: {:?}\n", plugin_dir));
|
||||
if let Some(layout_dir) = layout_dir {
|
||||
message.push_str(&format!("[LAYOUT DIR]: {:?}\n", layout_dir));
|
||||
} else {
|
||||
message.push_str("[CONFIG FILE]: Not Found\n");
|
||||
}
|
||||
message.push_str(&format!("[SYSTEM DATA DIR]: {:?}\n", system_data_dir));
|
||||
|
||||
message.push_str(&format!("[ARROW SEPARATOR]: {}\n", ARROW_SEPARATOR));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue