Update: ssh clone script takes output dirname
This commit is contained in:
parent
f02f0e183d
commit
6b5ec8ef6a
|
@ -18,6 +18,13 @@ parser.add_argument(
|
||||||
help="HTTP or ssh url to use",
|
help="HTTP or ssh url to use",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"out_name",
|
||||||
|
type=str,
|
||||||
|
nargs="?",
|
||||||
|
help="Name to use for the directory",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if m := HTTP_RE.fullmatch(args.url):
|
if m := HTTP_RE.fullmatch(args.url):
|
||||||
|
@ -28,7 +35,12 @@ else:
|
||||||
print(f"Failed to parse URL `{args.url}`", file=sys.stderr)
|
print(f"Failed to parse URL `{args.url}`", file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if "git.sr.ht" not in args.url and not ssh_url.endswith('.git'):
|
if "git.sr.ht" not in args.url and not ssh_url.endswith(".git"):
|
||||||
ssh_url += ".git"
|
ssh_url += ".git"
|
||||||
|
|
||||||
Popen(["git", "clone", ssh_url]).wait()
|
git_cmd = ["git", "clone", ssh_url]
|
||||||
|
|
||||||
|
if args.out_name is not None:
|
||||||
|
git_cmd.append(args.out_name)
|
||||||
|
|
||||||
|
Popen(git_cmd).wait()
|
||||||
|
|
|
@ -22,9 +22,14 @@ path = "src/rename_for_unix.rs"
|
||||||
name = "random_password"
|
name = "random_password"
|
||||||
path = "src/random_password.rs"
|
path = "src/random_password.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "prettify_markdown_notes"
|
||||||
|
path = "src/prettify_markdown_notes.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4"
|
chrono = "0.4.23"
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
|
lazy_static = "1.4.0"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
termion = "2"
|
termion = "2"
|
||||||
|
|
|
@ -73,7 +73,9 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if args.diceware.as_ref().unwrap().exists() {
|
} else if args.diceware.as_ref().unwrap().exists() {
|
||||||
let nb_lines = BufReader::new(File::open(args.diceware.as_ref().unwrap())
|
let wordlist: PathBuf = args.diceware.unwrap();
|
||||||
|
|
||||||
|
let nb_lines = BufReader::new(File::open(&wordlist)
|
||||||
.expect("Unable to open word-list file"))
|
.expect("Unable to open word-list file"))
|
||||||
.lines()
|
.lines()
|
||||||
.count();
|
.count();
|
||||||
|
@ -82,9 +84,21 @@ fn main() {
|
||||||
.map(|_| OsRng.next_u64() % nb_lines as u64)
|
.map(|_| OsRng.next_u64() % nb_lines as u64)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
pass = index_lines(args.diceware.as_ref().unwrap(), &indices)
|
pass = index_lines(&wordlist, &indices)
|
||||||
.unwrap()
|
.expect("Failed to index wordlist")
|
||||||
.join("8");
|
.join("_");
|
||||||
|
|
||||||
|
pass.push_str("_");
|
||||||
|
|
||||||
|
for _ in 0..args.pass_length {
|
||||||
|
let rand_digit = (OsRng.next_u64() % 10).to_string();
|
||||||
|
pass.push_str(&rand_digit);
|
||||||
|
}
|
||||||
|
|
||||||
|
pass.push_str("!!!");
|
||||||
|
|
||||||
|
// Capitalize first letter
|
||||||
|
pass = pass.chars().next().unwrap().to_uppercase().to_string() + &pass[1..];
|
||||||
|
|
||||||
trimmed = &pass;
|
trimmed = &pass;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue