summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/config
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2019-05-03 19:48:25 -0400
committerGitHub <noreply@github.com>2019-05-03 19:48:25 -0400
commit34c54e7e0eb7c28406df112d118b82280be2adee (patch)
tree7b32e11bed7906d67d43da81bd8e8b08f128660d /alacritty_terminal/src/config
parentba6e208a95e37116b031aca02246d3cff04c0216 (diff)
downloadalacritty-34c54e7e0eb7c28406df112d118b82280be2adee.tar.gz
alacritty-34c54e7e0eb7c28406df112d118b82280be2adee.zip
Add git hash to version string, and fix crate name (#2397)
This moves `cli` out of `alacritty_terminal` and into `alacritty` where it belongs, along with the `clap` dependency.
Diffstat (limited to 'alacritty_terminal/src/config')
-rw-r--r--alacritty_terminal/src/config/mod.rs5
-rw-r--r--alacritty_terminal/src/config/options.rs72
2 files changed, 75 insertions, 2 deletions
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs
index 9502e3fd..6eebbdfc 100644
--- a/alacritty_terminal/src/config/mod.rs
+++ b/alacritty_terminal/src/config/mod.rs
@@ -22,11 +22,12 @@ use serde::{self, de, Deserialize};
use serde_yaml;
use crate::ansi::CursorStyle;
-use crate::cli::Options;
use crate::index::{Column, Line};
use crate::input::{Action, Binding, KeyBinding, MouseBinding};
use crate::term::color::Rgb;
+pub use self::options::Options;
+mod options;
mod bindings;
pub const SOURCE_FILE_PATH: &str = file!();
@@ -2704,7 +2705,7 @@ impl Key {
#[cfg(test)]
mod tests {
use super::{Config, DEFAULT_ALACRITTY_CONFIG};
- use crate::cli::Options;
+ use crate::config::Options;
#[test]
fn parse_config() {
diff --git a/alacritty_terminal/src/config/options.rs b/alacritty_terminal/src/config/options.rs
new file mode 100644
index 00000000..4b4f1be0
--- /dev/null
+++ b/alacritty_terminal/src/config/options.rs
@@ -0,0 +1,72 @@
+// Copyright 2019 Joe Wilm, The Alacritty Project Contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+use ::log;
+
+use crate::config::{Delta, Dimensions, Shell};
+use std::borrow::Cow;
+use std::path::{Path, PathBuf};
+
+/// Options specified on the command line
+pub struct Options {
+ pub live_config_reload: Option<bool>,
+ pub print_events: bool,
+ pub ref_test: bool,
+ pub dimensions: Option<Dimensions>,
+ pub position: Option<Delta<i32>>,
+ pub title: Option<String>,
+ pub class: Option<String>,
+ pub log_level: log::LevelFilter,
+ pub command: Option<Shell<'static>>,
+ pub working_dir: Option<PathBuf>,
+ pub config: Option<PathBuf>,
+ pub persistent_logging: bool,
+}
+
+impl Default for Options {
+ fn default() -> Options {
+ Options {
+ live_config_reload: None,
+ print_events: false,
+ ref_test: false,
+ dimensions: None,
+ position: None,
+ title: None,
+ class: None,
+ log_level: log::LevelFilter::Warn,
+ command: None,
+ working_dir: None,
+ config: None,
+ persistent_logging: false,
+ }
+ }
+}
+
+impl Options {
+ pub fn dimensions(&self) -> Option<Dimensions> {
+ self.dimensions
+ }
+
+ pub fn position(&self) -> Option<Delta<i32>> {
+ self.position
+ }
+
+ pub fn command(&self) -> Option<&Shell<'_>> {
+ self.command.as_ref()
+ }
+
+ pub fn config_path(&self) -> Option<Cow<'_, Path>> {
+ self.config.as_ref().map(|p| Cow::Borrowed(p.as_path()))
+ }
+}