Skip to content

Commit

Permalink
feat: stubs of credential manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 16, 2024
1 parent 3903e9b commit d18a4fb
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
23 changes: 20 additions & 3 deletions src/credential_manager.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
pub struct Credential {
// user: String,
// password: String,
// totp_command: String
}

pub struct CredentialManager {
}

impl CredentialManager {
fn get_password(&self, user: &str, url: &str) {

pub fn get_credential(&self, url: &str) -> Credential {
Credential {
// user: "",
// password: ""
}
}

pub fn has_credential(&self, url: &str) -> bool {
true
}

pub fn remove_credential(&self, url: &str) {

}

fn set_password(&self, user: &str, url: &str, password: &str) {
pub fn set_credential(&self, url: &str, credential: &Credential) {

}
}
40 changes: 38 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,55 @@ fn cli() -> Command {
.help("The URL for the Synology NAS")
)
)
.subcommand(
Command::new("logout")
.about("Deletes a login for the Synology NAS.")
.args_conflicts_with_subcommands(true)
.flatten_help(true)
.arg(
Arg::new("URL")
.short('l')
.long("url")
.required(true)
.help("The URL for the Synology NAS")
)
)
}

fn login(user: &str, url: &str) {
let credential_manager = CredentialManager { };

if credential_manager.has_credential(url) {
// get password and totp command
}
else {
// get password and totop command
}

// try login
// if success store

// else throw error
}

fn login() {
fn logout(url: &str) {
let credential_manager = CredentialManager { };

if credential_manager.has_credential(url) {
credential_manager.remove_credential(url);
}
}

fn main() {
let matches = cli().get_matches();

match matches.subcommand() {
Some(("login", _)) => {
login();
// login();
},
Some(("logout", _)) => {
// logout();
}
_ => println!("No subcommand")
}
}

0 comments on commit d18a4fb

Please sign in to comment.