Add passing of overridable address to fn process

Ignore all variant members while using `todo!()`s
Add precedence info and mention of config / env var for address argument
This commit is contained in:
Aadi Desai 2023-05-09 00:37:30 +01:00
parent 40ebdf777d
commit 25ec3b53d7
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
11 changed files with 55 additions and 54 deletions

View file

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Address input parameter for fn `process` in `impl`s
### Changed ### Changed
### Deprecated ### Deprecated

View file

@ -13,7 +13,7 @@ pub enum Address {
} }
impl Address { impl Address {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Address::IsAvailable => todo!(), Address::IsAvailable => todo!(),
Address::GetExpiry => todo!(), Address::GetExpiry => todo!(),

View file

@ -22,12 +22,12 @@ pub enum Dns {
} }
impl Dns { impl Dns {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Dns::GetRecords => todo!(), Dns::GetRecords => todo!(),
Dns::AddRecord { json_data } => todo!(), Dns::AddRecord { json_data: _ } => todo!(),
Dns::UpdateRecord { json_data } => todo!(), Dns::UpdateRecord { json_data: _ } => todo!(),
Dns::DeleteRecord { id } => todo!(), Dns::DeleteRecord { id: _ } => todo!(),
} }
} }
} }

View file

@ -12,10 +12,10 @@ pub enum Email {
} }
impl Email { impl Email {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Email::GetForwards => todo!(), Email::GetForwards => todo!(),
Email::SetForwards { json_data } => todo!(), Email::SetForwards { json_data: _ } => todo!(),
} }
} }
} }

View file

@ -36,13 +36,13 @@ pub enum Commands {
}, },
/// Get information and make changes to your addresses /// Get information and make changes to your addresses
Address { Address {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
command: Address, command: Address,
}, },
/// Save your omg.lol API key to the config.json (Rather than using the OMGLOL_API_KEY environment variable) /// Save your omg.lol API key to the config.json (Rather than using the env. var: OMGLOL_API_KEY)
Auth { Auth {
/// API key to save to config.json /// API key to save to config.json
api_key: String, api_key: String,
@ -51,7 +51,7 @@ pub enum Commands {
Directory, Directory,
/// Adjust the switchboard / DNS records for your omg.lol address /// Adjust the switchboard / DNS records for your omg.lol address
Dns { Dns {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -59,7 +59,7 @@ pub enum Commands {
}, },
/// Manage the email configuration for an omg.lol address /// Manage the email configuration for an omg.lol address
Email { Email {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -67,7 +67,7 @@ pub enum Commands {
}, },
/// Manage your /now page /// Manage your /now page
Now { Now {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -75,7 +75,7 @@ pub enum Commands {
}, },
/// Manage the pastebin for an omg.lol address /// Manage the pastebin for an omg.lol address
Pastebin { Pastebin {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -92,7 +92,7 @@ pub enum Commands {
}, },
/// Manage PURLs (Persistent URLs) for your omg.lol address /// Manage PURLs (Persistent URLs) for your omg.lol address
Purl { Purl {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -102,7 +102,7 @@ pub enum Commands {
Service, Service,
/// Manage the statuslog for an omg.lol address /// Manage the statuslog for an omg.lol address
Status { Status {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -110,7 +110,7 @@ pub enum Commands {
}, },
/// Manage omg.lol profile themes /// Manage omg.lol profile themes
Theme { Theme {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -118,7 +118,7 @@ pub enum Commands {
}, },
/// Manage profile page and web stuff for an omg.lol address /// Manage profile page and web stuff for an omg.lol address
Web { Web {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -126,7 +126,7 @@ pub enum Commands {
}, },
/// Manage the weblog for an omg.lol address /// Manage the weblog for an omg.lol address
Weblog { Weblog {
/// omg.lol address to interact with /// omg.lol address to interact with, overrides config and env. var: (OMGLOL_USERNAME)
#[clap(short, long, global = true)] #[clap(short, long, global = true)]
address: Option<String>, address: Option<String>,
#[clap(subcommand)] #[clap(subcommand)]
@ -135,25 +135,24 @@ pub enum Commands {
} }
impl Commands { impl Commands {
fn process(&self) { // TBD: Is there a more idiomatic / succinct approach to this?
pub fn process(&self, _address: &Option<String>) {
match self { match self {
Commands::Account { email, command } => { Commands::Account { email, command } => command.process(email),
command.process(email); Commands::Address { address, command } => command.process(address),
} Commands::Auth { api_key: _ } => todo!(),
Commands::Address { address, command } => todo!(),
Commands::Auth { api_key } => todo!(),
Commands::Directory => todo!(), Commands::Directory => todo!(),
Commands::Dns { address, command } => todo!(), Commands::Dns { address, command } => command.process(address),
Commands::Email { address, command } => todo!(), Commands::Email { address, command } => command.process(address),
Commands::Now { address, command } => todo!(), Commands::Now { address, command } => command.process(address),
Commands::Pastebin { address, command } => todo!(), Commands::Pastebin { address, command } => command.process(address),
Commands::Preferences { owner, item, value } => todo!(), Commands::Preferences { owner: _, item: _, value: _ } => todo!(),
Commands::Purl { address, command } => todo!(), Commands::Purl { address, command } => command.process(address),
Commands::Service => todo!(), Commands::Service => todo!(),
Commands::Status { address, command } => todo!(), Commands::Status { address, command } => command.process(address),
Commands::Theme { address, command } => todo!(), Commands::Theme { address, command } => command.process(address),
Commands::Web { address, command } => todo!(), Commands::Web { address, command } => command.process(address),
Commands::Weblog { address, command } => todo!(), Commands::Weblog { address, command } => command.process(address),
} }
} }
} }

View file

@ -17,11 +17,11 @@ pub enum Now {
} }
impl Now { impl Now {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Now::Get => todo!(), Now::Get => todo!(),
Now::List => todo!(), Now::List => todo!(),
Now::Set { content, listed } => todo!(), Now::Set { content: _, listed: _ } => todo!(),
} }
} }
} }

View file

@ -26,13 +26,13 @@ pub enum Pastebin {
} }
impl Pastebin { impl Pastebin {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Pastebin::Get { name } => todo!(), Pastebin::Get { name: _ } => todo!(),
Pastebin::GetAll => todo!(), Pastebin::GetAll => todo!(),
Pastebin::GetAllPublic => todo!(), Pastebin::GetAllPublic => todo!(),
Pastebin::Set { name, content } => todo!(), Pastebin::Set { name: _, content: _ } => todo!(),
Pastebin::Delete { name } => todo!(), Pastebin::Delete { name: _ } => todo!(),
} }
} }
} }

View file

@ -24,12 +24,12 @@ pub enum Purl {
} }
impl Purl { impl Purl {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Purl::Create { name, url } => todo!(), Purl::Create { name: _, url: _ } => todo!(),
Purl::Get { name } => todo!(), Purl::Get { name: _ } => todo!(),
Purl::List => todo!(), Purl::List => todo!(),
Purl::Delete { name } => todo!(), Purl::Delete { name: _ } => todo!(),
} }
} }
} }

View file

@ -47,15 +47,15 @@ pub enum Status {
} }
impl Status { impl Status {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Status::Get { id } => todo!(), Status::Get { id: _ } => todo!(),
Status::GetAll => todo!(), Status::GetAll => todo!(),
Status::Create { emoji, content, external_url } => todo!(), Status::Create { emoji: _, content: _, external_url: _ } => todo!(),
Status::EasyCreate { status } => todo!(), Status::EasyCreate { status: _ } => todo!(),
Status::Update { id, emoji, content } => todo!(), Status::Update { id: _, emoji: _, content: _ } => todo!(),
Status::GetBio => todo!(), Status::GetBio => todo!(),
Status::SetBio { content } => todo!(), Status::SetBio { content: _ } => todo!(),
Status::GetAllHistorical => todo!(), Status::GetAllHistorical => todo!(),
Status::Timeline => todo!(), Status::Timeline => todo!(),
} }

View file

@ -17,11 +17,11 @@ pub enum Theme {
} }
impl Theme { impl Theme {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Theme::List => todo!(), Theme::List => todo!(),
Theme::Info { id } => todo!(), Theme::Info { id: _ } => todo!(),
Theme::Preview { id } => todo!(), Theme::Preview { id: _ } => todo!(),
} }
} }
} }

View file

@ -22,7 +22,7 @@ pub enum Web {
} }
impl Web { impl Web {
pub fn process(&self) { pub fn process(&self, _address: &Option<String>) {
match self { match self {
Web::Get => todo!(), Web::Get => todo!(),
Web::Set { content: _, publish: _ } => todo!(), Web::Set { content: _, publish: _ } => todo!(),