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: adds dot file default for rules #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
17 changes: 14 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashSet;
use std::fs;
use std::{env, fs};

use clap::Parser;

Expand All @@ -12,8 +12,8 @@ pub mod sdkman;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Filename of the YAML config file
#[arg(short, long)]
/// Filename of the YAML config file.
#[arg(short, long, default_value_t = get_rules_dotfile())]
file: String,

/// Just print out the commands that would be executed
Expand All @@ -25,6 +25,17 @@ struct Args {
no_uninstall: bool,
}

fn get_rules_dotfile() -> String {
format!(
"{}/{}",
match env::var_os("HOME") {
Some(v) => v.into_string().unwrap(),
None => panic!("$HOME environment variable is not set"),
},
String::from(".sdk-rules.yaml")
)
}

fn main() {
let args = Args::parse();

Expand Down
Loading