Skip to content

Commit

Permalink
Merge pull request #5 from Ramilito/feature/add-inplace-and-path
Browse files Browse the repository at this point in the history
added inplace and path inputs
  • Loading branch information
Ramilito authored Dec 1, 2023
2 parents 763e9db + c0ccfaf commit eb4f1c3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ configs:
kubediff -e dev
```

**_You can also bypass the config by passing either -path or -inplace argument:_**
```
kubediff -p ~/path-to-kustomize-dir
kubediff -i
```
## Roadmap

- [ ] Remove, make optional or include dependency on yq
Expand Down
28 changes: 23 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,46 @@ mod print;
mod settings;

use clap::Parser;
use print::{pretty_print, pretty_print_info, pretty_print_path};
use commands::{get_build, get_diff};
use print::{pretty_print, pretty_print_info, pretty_print_path};
use serde::Deserialize;
use serde_yaml::Value;
use settings::Settings;
use std::io::{self, Write};
use std::{
collections::HashSet,
env,
io::{self, Write},
};

#[derive(Debug, Parser)]
#[clap(author, version, about, long_about = None)]
pub struct Cli {
#[clap(short, long, value_parser)]
env: Option<String>,
#[clap(short, long, value_parser)]
inplace: bool,
#[clap(short, long, value_parser)]
path: Option<String>,
#[clap(short, long, action)]
verbose: bool,
}

fn main() -> Result<(), io::Error> {
let args = Cli::parse();
let mut settings = Settings::load()?;
let mut entry = HashSet::new();

if args.inplace {
let cwd = env::current_dir().unwrap().to_str().unwrap().to_string();
entry.insert(cwd);
} else if args.path.is_some() {
let path = args.path.unwrap();
entry.insert(path);
} else {
let mut settings = Settings::load()?;

settings.configs.env = args.env.unwrap_or_default();
let entry = Settings::get_service_paths(&settings)?;
settings.configs.env = args.env.unwrap_or_default();
entry = Settings::get_service_paths(&settings)?;
}

for path in entry {
pretty_print_path(format!("Path: {}", path.to_string()));
Expand Down

0 comments on commit eb4f1c3

Please sign in to comment.