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
- Address input parameter for fn `process` in `impl`s
### Changed
### Deprecated

View file

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

View file

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

View file

@ -12,10 +12,10 @@ pub enum Email {
}
impl Email {
pub fn process(&self) {
pub fn process(&self, _address: &Option<String>) {
match self {
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
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)]
address: Option<String>,
#[clap(subcommand)]
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 {
/// API key to save to config.json
api_key: String,
@ -51,7 +51,7 @@ pub enum Commands {
Directory,
/// Adjust the switchboard / DNS records for your omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -59,7 +59,7 @@ pub enum Commands {
},
/// Manage the email configuration for an omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -67,7 +67,7 @@ pub enum Commands {
},
/// Manage your /now page
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)]
address: Option<String>,
#[clap(subcommand)]
@ -75,7 +75,7 @@ pub enum Commands {
},
/// Manage the pastebin for an omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -92,7 +92,7 @@ pub enum Commands {
},
/// Manage PURLs (Persistent URLs) for your omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -102,7 +102,7 @@ pub enum Commands {
Service,
/// Manage the statuslog for an omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -110,7 +110,7 @@ pub enum Commands {
},
/// Manage omg.lol profile themes
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)]
address: Option<String>,
#[clap(subcommand)]
@ -118,7 +118,7 @@ pub enum Commands {
},
/// Manage profile page and web stuff for an omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -126,7 +126,7 @@ pub enum Commands {
},
/// Manage the weblog for an omg.lol address
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)]
address: Option<String>,
#[clap(subcommand)]
@ -135,25 +135,24 @@ pub enum 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 {
Commands::Account { email, command } => {
command.process(email);
}
Commands::Address { address, command } => todo!(),
Commands::Auth { api_key } => todo!(),
Commands::Account { email, command } => command.process(email),
Commands::Address { address, command } => command.process(address),
Commands::Auth { api_key: _ } => todo!(),
Commands::Directory => todo!(),
Commands::Dns { address, command } => todo!(),
Commands::Email { address, command } => todo!(),
Commands::Now { address, command } => todo!(),
Commands::Pastebin { address, command } => todo!(),
Commands::Preferences { owner, item, value } => todo!(),
Commands::Purl { address, command } => todo!(),
Commands::Dns { address, command } => command.process(address),
Commands::Email { address, command } => command.process(address),
Commands::Now { address, command } => command.process(address),
Commands::Pastebin { address, command } => command.process(address),
Commands::Preferences { owner: _, item: _, value: _ } => todo!(),
Commands::Purl { address, command } => command.process(address),
Commands::Service => todo!(),
Commands::Status { address, command } => todo!(),
Commands::Theme { address, command } => todo!(),
Commands::Web { address, command } => todo!(),
Commands::Weblog { address, command } => todo!(),
Commands::Status { address, command } => command.process(address),
Commands::Theme { address, command } => command.process(address),
Commands::Web { address, command } => command.process(address),
Commands::Weblog { address, command } => command.process(address),
}
}
}

View file

@ -17,11 +17,11 @@ pub enum Now {
}
impl Now {
pub fn process(&self) {
pub fn process(&self, _address: &Option<String>) {
match self {
Now::Get => 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 {
pub fn process(&self) {
pub fn process(&self, _address: &Option<String>) {
match self {
Pastebin::Get { name } => todo!(),
Pastebin::Get { name: _ } => todo!(),
Pastebin::GetAll => todo!(),
Pastebin::GetAllPublic => todo!(),
Pastebin::Set { name, content } => todo!(),
Pastebin::Delete { name } => todo!(),
Pastebin::Set { name: _, content: _ } => todo!(),
Pastebin::Delete { name: _ } => todo!(),
}
}
}

View file

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

View file

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

View file

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

View file

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