Merge pull request #431 from a-kenji/rename-install

Rename install -> setup
This commit is contained in:
a-kenji 2021-05-02 16:11:26 +02:00 committed by GitHub
commit 882de91191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 29 deletions

View file

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* Fix the tab '(Sync)' suffix in named tabs (https://github.com/zellij-org/zellij/pull/410) * Fix the tab '(Sync)' suffix in named tabs (https://github.com/zellij-org/zellij/pull/410)
* Improve performance when multiple panes are open (https://github.com/zellij-org/zellij/pull/318) * Improve performance when multiple panes are open (https://github.com/zellij-org/zellij/pull/318)
* Improve error reporting and tests of configuration (https://github.com/zellij-org/zellij/pull/423) * Improve error reporting and tests of configuration (https://github.com/zellij-org/zellij/pull/423)
* Refactor install module to setup module (https://github.com/zellij-org/zellij/pull/431)
## [0.6.0] - 2021-04-29 ## [0.6.0] - 2021-04-29
* Doesn't quit anymore on single `q` press while in tab mode (https://github.com/zellij-org/zellij/pull/342) * Doesn't quit anymore on single `q` press while in tab mode (https://github.com/zellij-org/zellij/pull/342)

View file

@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
use super::keybinds::{Keybinds, KeybindsFromYaml}; use super::keybinds::{Keybinds, KeybindsFromYaml};
use crate::cli::{CliArgs, ConfigCli}; use crate::cli::{CliArgs, ConfigCli};
use crate::common::install; use crate::common::setup;
use serde::Deserialize; use serde::Deserialize;
use std::convert::TryFrom; use std::convert::TryFrom;
@ -61,7 +61,10 @@ impl TryFrom<&CliArgs> for Config {
} }
} }
let config_dir = opts.config_dir.clone().or_else(install::default_config_dir); let config_dir = opts
.config_dir
.clone()
.or_else(setup::find_default_config_dir);
if let Some(ref config) = config_dir { if let Some(ref config) = config_dir {
let path = config.join(DEFAULT_CONFIG_FILE_NAME); let path = config.join(DEFAULT_CONFIG_FILE_NAME);
@ -101,7 +104,7 @@ impl Config {
// TODO Deserialize the Configuration from bytes &[u8], // TODO Deserialize the Configuration from bytes &[u8],
// once serde-yaml supports zero-copy // once serde-yaml supports zero-copy
pub fn from_default_assets() -> ConfigResult { pub fn from_default_assets() -> ConfigResult {
Self::from_yaml(String::from_utf8(install::DEFAULT_CONFIG.to_vec())?.as_str()) Self::from_yaml(String::from_utf8(setup::DEFAULT_CONFIG.to_vec())?.as_str())
} }
} }

View file

@ -1,11 +1,11 @@
pub mod command_is_executing; pub mod command_is_executing;
pub mod errors; pub mod errors;
pub mod input; pub mod input;
pub mod install;
pub mod ipc; pub mod ipc;
pub mod os_input_output; pub mod os_input_output;
pub mod pty_bus; pub mod pty_bus;
pub mod screen; pub mod screen;
pub mod setup;
pub mod utils; pub mod utils;
pub mod wasm_vm; pub mod wasm_vm;
@ -34,11 +34,11 @@ use errors::{
ScreenContext, ScreenContext,
}; };
use input::handler::input_loop; use input::handler::input_loop;
use install::populate_data_dir;
use os_input_output::OsApi; use os_input_output::OsApi;
use pty_bus::{PtyBus, PtyInstruction}; use pty_bus::{PtyBus, PtyInstruction};
use screen::{Screen, ScreenInstruction}; use screen::{Screen, ScreenInstruction};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use setup::install;
use utils::consts::ZELLIJ_IPC_PIPE; use utils::consts::ZELLIJ_IPC_PIPE;
use wasm_vm::{wasi_read_string, wasi_write_object, zellij_exports, PluginEnv, PluginInstruction}; use wasm_vm::{wasi_read_string, wasi_write_object, zellij_exports, PluginEnv, PluginInstruction};
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value}; use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
@ -168,7 +168,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
let data_dir = opts let data_dir = opts
.data_dir .data_dir
.unwrap_or_else(|| project_dirs.data_dir().to_path_buf()); .unwrap_or_else(|| project_dirs.data_dir().to_path_buf());
populate_data_dir(&data_dir); install::populate_data_dir(&data_dir);
// Don't use default layouts in tests, but do everywhere else // Don't use default layouts in tests, but do everywhere else
#[cfg(not(test))] #[cfg(not(test))]

View file

@ -4,6 +4,7 @@ use std::io::Write;
use std::{fs, path::Path, path::PathBuf}; use std::{fs, path::Path, path::PathBuf};
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");
const CONFIG_LOCATION: &str = "/.config/zellij";
#[macro_export] #[macro_export]
macro_rules! asset_map { macro_rules! asset_map {
@ -18,6 +19,9 @@ macro_rules! asset_map {
} }
} }
pub mod install {
use super::*;
pub fn populate_data_dir(data_dir: &Path) { pub fn populate_data_dir(data_dir: &Path) {
// First run installation of default plugins & layouts // First run installation of default plugins & layouts
let mut assets = asset_map! { let mut assets = asset_map! {
@ -42,8 +46,9 @@ pub fn populate_data_dir(data_dir: &Path) {
} }
} }
} }
}
pub fn default_config_dir() -> Option<PathBuf> { pub fn find_default_config_dir() -> Option<PathBuf> {
vec![ vec![
Some(xdg_config_dir()), Some(xdg_config_dir()),
home_config_dir(), home_config_dir(),
@ -62,7 +67,7 @@ pub fn xdg_config_dir() -> PathBuf {
pub fn home_config_dir() -> Option<PathBuf> { pub fn home_config_dir() -> Option<PathBuf> {
if let Some(user_dirs) = BaseDirs::new() { if let Some(user_dirs) = BaseDirs::new() {
let config_dir = user_dirs.home_dir().join("/.config/zellij"); let config_dir = user_dirs.home_dir().join(CONFIG_LOCATION);
Some(config_dir) Some(config_dir)
} else { } else {
None None

View file

@ -15,7 +15,7 @@ use crate::utils::{
}; };
use client::{boundaries, layout, panes, tab}; use client::{boundaries, layout, panes, tab};
use common::{ use common::{
command_is_executing, errors, install, os_input_output, pty_bus, screen, start, utils, wasm_vm, command_is_executing, errors, os_input_output, pty_bus, screen, setup, start, utils, wasm_vm,
ApiCommand, ApiCommand,
}; };
use std::convert::TryFrom; use std::convert::TryFrom;
@ -69,7 +69,7 @@ pub fn main() {
let mut out = std::io::stdout(); let mut out = std::io::stdout();
CliArgs::clap().gen_completions_to("zellij", shell, &mut out); CliArgs::clap().gen_completions_to("zellij", shell, &mut out);
} else if let Some(crate::cli::ConfigCli::Setup { .. }) = opts.option { } else if let Some(crate::cli::ConfigCli::Setup { .. }) = opts.option {
install::dump_default_config().expect("Failed to print to stdout"); setup::dump_default_config().expect("Failed to print to stdout");
std::process::exit(1); std::process::exit(1);
} else { } else {
let os_input = get_os_input(); let os_input = get_os_input();