Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(console): Support config file #320

Merged
merged 20 commits into from
Apr 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(console): fix variant name
nrskt committed Apr 12, 2022
commit 2da4fdfc4b77ebf098130a8409c9ae6218cfc82c
16 changes: 8 additions & 8 deletions tokio-console/src/config.rs
Original file line number Diff line number Diff line change
@@ -149,15 +149,15 @@ pub struct ColorsConfig {

impl Config {
pub fn from_config() -> color_eyre::Result<Self> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if from_config() is the best name for this, since it also parses the config from the command line arguments as well?

let xdg = ViewOptions::from_config(ConfigPath::Xdg)?;
let home = ViewOptions::from_config(ConfigPath::Home)?;
let current = ViewOptions::from_config(ConfigPath::Current)?;
let base = match (xdg, current) {
let base = match (home, current) {
(None, None) => None,
(Some(xdg), None) => Some(xdg),
(Some(home), None) => Some(home),
(None, Some(current)) => Some(current),
(Some(mut xdg), Some(current)) => {
xdg.merge_with(current);
Some(xdg)
(Some(mut home), Some(current)) => {
home.merge_with(current);
Some(home)
}
};
let mut config = Self::parse();
@@ -378,14 +378,14 @@ impl ConfigFile {

#[derive(Debug, Clone, Copy)]
enum ConfigPath {
Xdg,
Home,
Current,
}

impl ConfigPath {
fn into_path(self) -> Option<PathBuf> {
match self {
Self::Xdg => {
Self::Home => {
let mut path = dirs::config_dir();
if let Some(path) = path.as_mut() {
path.push("tokio-console/console.toml");