Skip to content

Commit

Permalink
feat: logout subcommand stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 16, 2024
1 parent cdb2d8f commit de4b817
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 48 deletions.
13 changes: 0 additions & 13 deletions src/commands/login_command.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/commands/mod.rs

This file was deleted.

36 changes: 6 additions & 30 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use clap::{Command, Arg};

mod commands;
mod subcommands;
mod credential_manager;

use commands::{Subcommand, LoginCommand};
use credential_manager::CredentialManager;
use subcommands::{LoginSubcommand, LogoutSubcommand, Subcommand};

fn cli() -> Command {
Command::new("git-lfs-synology")
Expand Down Expand Up @@ -45,40 +44,17 @@ fn cli() -> Command {
)
}

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 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", sub_matches)) => {
let login_command = LoginCommand { };
let login_command = LoginSubcommand { };
login_command.execute(sub_matches);
},
Some(("logout", _)) => {
// logout();
Some(("logout", sub_matches)) => {
let logout_command = LogoutSubcommand { };
logout_command.execute(sub_matches);
}
_ => println!("No subcommand")
}
Expand Down
32 changes: 32 additions & 0 deletions src/subcommands/login_subcommand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use clap::ArgMatches;

use crate::subcommands::Subcommand;
use crate::credential_manager::CredentialManager;

pub struct LoginSubcommand {

}

impl LoginSubcommand {
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
}
}

impl Subcommand for LoginSubcommand {
fn execute(&self, arg_matches: &ArgMatches) {

}
}
22 changes: 22 additions & 0 deletions src/subcommands/logout_subcommand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::subcommands::subcommand::Subcommand;
use crate::credential_manager::CredentialManager;

pub struct LogoutSubcommand {

}

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

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

impl Subcommand for LogoutSubcommand {
fn execute(&self, arg_matches: &clap::ArgMatches) {

}
}
7 changes: 7 additions & 0 deletions src/subcommands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod subcommand;
mod login_subcommand;
mod logout_subcommand;

pub use login_subcommand::LoginSubcommand;
pub use logout_subcommand::LogoutSubcommand;
pub use subcommand::Subcommand;
File renamed without changes.

0 comments on commit de4b817

Please sign in to comment.