Skip to content

Commit

Permalink
Added a way to generate a man file, and also added support for -h/--help
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkjall committed Aug 31, 2019
1 parent 390afc2 commit 5b9b278
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ tempfile = "3.1.0"
[workspace]

members = [
"gtk","qml", "cursive"
"gtk", "qml", "cursive", "man"
]
17 changes: 17 additions & 0 deletions cursive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,26 @@ fn search(passwords: &pass::PasswordList, ui: &mut Cursive, query: &str) -> () {
});
}

fn help() {
println!("A password manager that uses the file format of the standard unix password manager 'pass', implemented in rust.
Ripasso reads $HOME/.password-store/ by default, override this by setting the PASSWORD_STORE_DIR environmental variable.");
}

fn main() {
env_logger::init();

let args: Vec<String> = std::env::args().collect();

match args.len() {
2 => {
if args[1] == "-h" || args[1] == "--help" {
help();
std::process::exit(0);
}
},
_ => {}
}

// Load and watch all the passwords in the background
let (password_rx, passwords) = match pass::watch() {
Ok(t) => t,
Expand Down
7 changes: 7 additions & 0 deletions man/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "ripasso-man"
version = "0.1.0"
authors = ["Alexander Kjäll <alexander.kjall@gmail.com>"]

[dependencies]
man = "0.3.0"
20 changes: 20 additions & 0 deletions man/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extern crate man;

fn main() {
let page = man::prelude::Manual::new("ripasso")
.about("A password manager that uses the file format of the standard unix password manager 'pass', implemented in rust.")
.author(man::prelude::Author::new("Joakim Lundborg").email("joakim.lundborg@gmail.com"))
.author(man::prelude::Author::new("Alexander Kjäll").email("alexander.kjall@gmail.com"))
.flag(man::prelude::Flag::new()
.short("-h")
.long("--help")
.help("Print a help text"),
)
.custom(man::prelude::Section::new("usage note")
.paragraph("Ripasso reads $HOME/.password-store/ by default, override this by setting
the PASSWORD_STORE_DIR environmental variable.")
)
.render();

println!("{}", page);
}

0 comments on commit 5b9b278

Please sign in to comment.