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",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"out_name",
|
||||
type=str,
|
||||
nargs="?",
|
||||
help="Name to use for the directory",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if m := HTTP_RE.fullmatch(args.url):
|
||||
|
@ -28,7 +35,12 @@ else:
|
|||
print(f"Failed to parse URL `{args.url}`", file=sys.stderr)
|
||||
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"
|
||||
|
||||
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"
|
||||
path = "src/random_password.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "prettify_markdown_notes"
|
||||
path = "src/prettify_markdown_notes.rs"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4"
|
||||
chrono = "0.4.23"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
lazy_static = "1.4.0"
|
||||
rand = "0.8"
|
||||
regex = "1"
|
||||
termion = "2"
|
||||
|
|
|
@ -73,7 +73,9 @@ fn main() {
|
|||
}
|
||||
}
|
||||
} 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"))
|
||||
.lines()
|
||||
.count();
|
||||
|
@ -82,9 +84,21 @@ fn main() {
|
|||
.map(|_| OsRng.next_u64() % nb_lines as u64)
|
||||
.collect();
|
||||
|
||||
pass = index_lines(args.diceware.as_ref().unwrap(), &indices)
|
||||
.unwrap()
|
||||
.join("8");
|
||||
pass = index_lines(&wordlist, &indices)
|
||||
.expect("Failed to index wordlist")
|
||||
.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;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue