-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: logout command implemented. login command started.
- Loading branch information
Showing
6 changed files
with
32 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
use crate::subcommands::subcommand::Subcommand; | ||
use crate::credential_manager::CredentialManager; | ||
|
||
pub struct LogoutSubcommand { | ||
url: String | ||
} | ||
use anyhow::{Context, Result}; | ||
use clap::ArgMatches; | ||
|
||
impl LogoutSubcommand { | ||
pub fn new() -> LogoutSubcommand { | ||
// Intentionally pass an empty string instead of using Some. | ||
// Url is required and will be handled by parsing. | ||
// We will still check during execution to see if the url is set just in case. | ||
LogoutSubcommand { | ||
url: "".to_string() | ||
} | ||
} | ||
pub struct LogoutSubcommand { | ||
} | ||
|
||
impl Subcommand for LogoutSubcommand { | ||
fn execute(&self) { | ||
let url = self.url.as_str(); | ||
let credential_manager = CredentialManager { }; | ||
|
||
// if credential_manager.has_credential(url) { | ||
// credential_manager.remove_credential(url); | ||
// } | ||
} | ||
fn execute(&self, arg_matches: &ArgMatches) -> Result<()> { | ||
let url = arg_matches.get_one::<String>("URL").context("URL not provided.")?; | ||
|
||
fn parse_args(&mut self, arg_matches: &clap::ArgMatches) -> Option<()> { | ||
let url = arg_matches.get_one::<String>("URL")?; | ||
self.url = url.clone(); | ||
let credential_manager = CredentialManager { }; | ||
credential_manager.remove_credential(url)?; | ||
|
||
Some(()) | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use anyhow::Result; | ||
use clap::ArgMatches; | ||
|
||
pub trait Subcommand { | ||
fn execute(&self); | ||
fn parse_args(&mut self, arg_matches: &ArgMatches) -> Option<()>; | ||
fn execute(&self, arg_matches: &ArgMatches) -> Result<()>; | ||
} |