mirror of
https://github.com/002Hub/IPass.git
synced 2025-04-19 13:51:21 +02:00
Init ig
Co-authored-by: Alpisc <Alpisc@users.noreply.github.com>
This commit is contained in:
commit
77aeba49b1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
41
Cargo.lock
generated
Normal file
41
Cargo.lock
generated
Normal file
@ -0,0 +1,41 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "747309b4b440c06d57b0b25f2aee03ee9b5e5397d288c60e21fc709bb98a7408"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipass"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"home",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "ipass"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
home = "0.5.4"
|
131
src/main.rs
Normal file
131
src/main.rs
Normal file
@ -0,0 +1,131 @@
|
||||
use std::collections::HashMap;
|
||||
use home::home_dir;
|
||||
use std::fs;
|
||||
|
||||
fn get_args() -> Vec<String> {
|
||||
std::env::args().collect() // [0] = file path; [n>0] = argument
|
||||
}
|
||||
|
||||
fn get_home_folder_str() -> String {
|
||||
match home::home_dir() {
|
||||
Some(path) => {
|
||||
let p = path.to_str();
|
||||
match p {
|
||||
Some(pa) => return pa.to_owned(),
|
||||
None => return "".to_owned(),
|
||||
}
|
||||
},
|
||||
None => return "".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_ipass_folder() -> String {
|
||||
let path = get_home_folder_str()+"/.IPass/";
|
||||
fs::create_dir_all(&path).unwrap();
|
||||
return path;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = get_args();
|
||||
|
||||
if args.len()<2 {
|
||||
help_message()
|
||||
}
|
||||
|
||||
let mode: &str = &args[1].trim().to_lowercase().to_owned();
|
||||
|
||||
match mode {
|
||||
"list" => list(),
|
||||
"add" => add(),
|
||||
"get" => get(),
|
||||
"edit" => edit(),
|
||||
"remove" => remove(),
|
||||
_ => help_message(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn help_message() {
|
||||
|
||||
let version = "0.0.1";
|
||||
println!("IPass v{}\n", version);
|
||||
|
||||
let args = get_args();
|
||||
|
||||
let mut help_messages:HashMap<String, String> = HashMap::new();
|
||||
help_messages.insert(
|
||||
"list".to_string(),
|
||||
"returns a list of all saved entries".to_string(),
|
||||
);
|
||||
help_messages.insert(
|
||||
"add".to_string(),
|
||||
"creates a new entry taking a [name] and an optional {password} ".to_string(),
|
||||
);
|
||||
help_messages.insert(
|
||||
"get".to_string(),
|
||||
"returns a specific entry, selected by the provided [name]".to_string(),
|
||||
);
|
||||
help_messages.insert(
|
||||
"help".to_string(),
|
||||
"tells you this message, takes an optional {command name}".to_string(),
|
||||
);
|
||||
help_messages.insert(
|
||||
"edit".to_string(),
|
||||
"lets you edit an existing entry, given the name and the new password".to_string(),
|
||||
);
|
||||
help_messages.insert(
|
||||
"remove".to_string(),
|
||||
"removes an existing entry".to_string(),
|
||||
);
|
||||
|
||||
if args.len()<3 {
|
||||
print!("The possible commands are: ");
|
||||
for i in help_messages.keys() {
|
||||
print!("\"{i}\" ");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
println!("{} {}", &args[2], &help_messages[&args[2]])
|
||||
}
|
||||
|
||||
fn get_pw() -> String {
|
||||
let mut output: String = String::new();
|
||||
std::io::stdin().read_line(&mut output).expect("Failed to read line");
|
||||
return output.replace("\n", "").replace("\r","");
|
||||
}
|
||||
|
||||
fn list() {
|
||||
todo!("List websites/names");
|
||||
}
|
||||
|
||||
fn add() {
|
||||
todo!("Add password")
|
||||
// create_entry(args[3],encrypt_pass(args[4]));
|
||||
}
|
||||
|
||||
fn get() {
|
||||
todo!("Get password")
|
||||
}
|
||||
|
||||
fn edit() {
|
||||
todo!("Edit entry")
|
||||
}
|
||||
|
||||
fn remove() {
|
||||
todo!("Removes entry")
|
||||
}
|
||||
|
||||
fn encrypt_pass(pass: &str) -> &str {
|
||||
return pass;
|
||||
}
|
||||
|
||||
/*
|
||||
prog.exe list -> all saved entries
|
||||
prog.exe add [Name] \n **in stars** {password}
|
||||
prog.exe get [Name]
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user