refactor: Add FullCtx which is Ctx with AppConfig
This commit is contained in:
parent
69f62d1767
commit
159f03320f
9 changed files with 193 additions and 144 deletions
103
src/config.rs
103
src/config.rs
|
@ -1,80 +1,30 @@
|
||||||
//
|
//
|
||||||
// use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
// f,
|
f,
|
||||||
nextcloud::model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername},
|
nextcloud::model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername},
|
||||||
// s,
|
s,
|
||||||
// trello::types::{TrelloApiKey, TrelloApiSecret, TrelloAuth, TrelloBoardName, TrelloUser},
|
trello::types::{
|
||||||
// Ctx, NAME,
|
auth::{TrelloApiKey, TrelloApiSecret},
|
||||||
|
TrelloBoardName,
|
||||||
|
},
|
||||||
|
Ctx, NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, derive_more::From, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
||||||
Clone,
|
|
||||||
Debug,
|
|
||||||
derive_more::From,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
serde::Deserialize,
|
|
||||||
derive_more::Constructor,
|
|
||||||
)]
|
|
||||||
pub struct TrelloConfig {
|
pub struct TrelloConfig {
|
||||||
pub user: String,
|
pub(crate) api_key: TrelloApiKey,
|
||||||
pub api_key: String,
|
pub(crate) api_secret: TrelloApiSecret,
|
||||||
pub api_secret: String,
|
pub(crate) board_name: TrelloBoardName,
|
||||||
pub board_name: String,
|
|
||||||
}
|
}
|
||||||
// impl TrelloConfig {
|
|
||||||
// pub fn user(&self) -> TrelloUser {
|
|
||||||
// TrelloUser::from(self.user.clone())
|
|
||||||
// }
|
|
||||||
// pub fn api_key(&self) -> TrelloApiKey {
|
|
||||||
// TrelloApiKey::from(self.api_key.clone())
|
|
||||||
// }
|
|
||||||
// pub fn api_secret(&self) -> TrelloApiSecret {
|
|
||||||
// TrelloApiSecret::from(self.api_secret.clone())
|
|
||||||
// }
|
|
||||||
// pub fn auth(&self) -> TrelloAuth {
|
|
||||||
// TrelloAuth::new(self.api_key(), self.api_secret(), self.user())
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pub fn board_name(&self) -> TrelloBoardName {
|
|
||||||
// TrelloBoardName::from(self.board_name.clone())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Debug, derive_more::From, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
||||||
Clone,
|
|
||||||
Debug,
|
|
||||||
derive_more::From,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
serde::Deserialize,
|
|
||||||
derive_more::Constructor,
|
|
||||||
)]
|
|
||||||
pub struct NextcloudConfig {
|
pub struct NextcloudConfig {
|
||||||
hostname: NextcloudHostname,
|
pub(crate) hostname: NextcloudHostname,
|
||||||
username: NextcloudUsername,
|
pub(crate) username: NextcloudUsername,
|
||||||
password: NextcloudPassword,
|
pub(crate) password: NextcloudPassword,
|
||||||
board_id: NextcloudBoardId,
|
pub(crate) board_id: NextcloudBoardId,
|
||||||
}
|
|
||||||
impl NextcloudConfig {
|
|
||||||
pub fn hostname(&self) -> &NextcloudHostname {
|
|
||||||
&self.hostname
|
|
||||||
}
|
|
||||||
pub fn username(&self) -> &NextcloudUsername {
|
|
||||||
&self.username
|
|
||||||
}
|
|
||||||
pub fn password(&self) -> &NextcloudPassword {
|
|
||||||
&self.password
|
|
||||||
}
|
|
||||||
pub fn board_id(&self) -> NextcloudBoardId {
|
|
||||||
self.board_id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
@ -87,16 +37,15 @@ impl NextcloudConfig {
|
||||||
Ord,
|
Ord,
|
||||||
derive_more::AsRef,
|
derive_more::AsRef,
|
||||||
serde::Deserialize,
|
serde::Deserialize,
|
||||||
derive_more::Constructor,
|
|
||||||
)]
|
)]
|
||||||
pub struct AppConfig {
|
pub struct AppConfig {
|
||||||
pub trello: TrelloConfig,
|
pub(crate) trello: TrelloConfig,
|
||||||
pub nextcloud: NextcloudConfig,
|
pub(crate) nextcloud: NextcloudConfig,
|
||||||
|
}
|
||||||
|
impl AppConfig {
|
||||||
|
pub fn load(ctx: &Ctx) -> Result<Self> {
|
||||||
|
let file = ctx.fs.base().join(f!("{NAME}.toml"));
|
||||||
|
let str = ctx.fs.file(&file).reader()?;
|
||||||
|
Ok(toml::from_str(s!(str).as_str())?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// impl AppConfig {
|
|
||||||
// pub fn load(ctx: &Ctx) -> Result<Self> {
|
|
||||||
// let file = ctx.fs.base().join(f!("{NAME}.toml"));
|
|
||||||
// let str = ctx.fs.file(&file).reader()?;
|
|
||||||
// Ok(toml::from_str(s!(str).as_str())?)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
39
src/lib.rs
39
src/lib.rs
|
@ -2,6 +2,7 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use color_eyre::eyre::eyre;
|
||||||
pub use config::AppConfig;
|
pub use config::AppConfig;
|
||||||
use kxio::{fs::FileSystem, net::Net};
|
use kxio::{fs::FileSystem, net::Net};
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ mod init;
|
||||||
mod macros;
|
mod macros;
|
||||||
pub mod nextcloud;
|
pub mod nextcloud;
|
||||||
mod template;
|
mod template;
|
||||||
// mod trello;
|
mod trello;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -45,16 +46,38 @@ impl Default for Ctx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct FullCtx {
|
||||||
|
pub fs: FileSystem,
|
||||||
|
pub net: Net,
|
||||||
|
pub cfg: AppConfig,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(test, mutants::skip)]
|
#[cfg_attr(test, mutants::skip)]
|
||||||
pub async fn run(ctx: Ctx) -> color_eyre::Result<()> {
|
pub async fn run(ctx: Ctx) -> color_eyre::Result<()> {
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
|
|
||||||
let commands = Commands::parse();
|
let commands = Commands::parse();
|
||||||
match commands.command {
|
let cfg = AppConfig::load(&ctx);
|
||||||
Command::Init => init::run(&ctx)?,
|
match cfg {
|
||||||
Command::Check => todo!("check"),
|
Err(err) => {
|
||||||
Command::Import => todo!("import"),
|
if matches!(commands.command, Command::Init) {
|
||||||
};
|
init::run(&ctx)
|
||||||
|
} else {
|
||||||
Ok(())
|
Err(eyre!("Missing or invalid config: {err}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(cfg) => {
|
||||||
|
let _ctx = FullCtx {
|
||||||
|
fs: ctx.fs,
|
||||||
|
net: ctx.net,
|
||||||
|
cfg,
|
||||||
|
};
|
||||||
|
match commands.command {
|
||||||
|
Command::Init => Err(eyre!("Config file already exists. Not overwriting it.")),
|
||||||
|
Command::Check => todo!("check"),
|
||||||
|
Command::Import => todo!("import"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ use kxio::net::Net;
|
||||||
use crate::api_result::APIResult;
|
use crate::api_result::APIResult;
|
||||||
use crate::{config::NextcloudConfig, f};
|
use crate::{config::NextcloudConfig, f};
|
||||||
|
|
||||||
|
use crate::nextcloud::model::{NextcloudHostname, NextcloudPassword, NextcloudUsername};
|
||||||
use model::{Board, Card, NextcloudBoardId, Stack};
|
use model::{Board, Card, NextcloudBoardId, Stack};
|
||||||
|
|
||||||
pub mod model;
|
pub mod model;
|
||||||
|
@ -11,24 +12,20 @@ pub mod model;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub struct DeckClient {
|
pub struct DeckClient<'cfg> {
|
||||||
net: Net,
|
net: Net,
|
||||||
hostname: String,
|
hostname: &'cfg NextcloudHostname,
|
||||||
username: String,
|
username: &'cfg NextcloudUsername,
|
||||||
password: String,
|
password: &'cfg NextcloudPassword,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeckClient {
|
impl<'cfg> DeckClient<'cfg> {
|
||||||
pub fn new(cfg: &NextcloudConfig, net: Net) -> Self {
|
pub fn new(cfg: &'cfg NextcloudConfig, net: Net) -> Self {
|
||||||
let hostname = cfg.hostname().to_string();
|
|
||||||
let username = cfg.username().to_string();
|
|
||||||
let password = cfg.password().to_string();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
net,
|
net,
|
||||||
hostname,
|
hostname: &cfg.hostname,
|
||||||
username,
|
username: &cfg.username,
|
||||||
password,
|
password: &cfg.password,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +41,7 @@ impl DeckClient {
|
||||||
APIResult::new(
|
APIResult::new(
|
||||||
self.net
|
self.net
|
||||||
.get(self.url("boards"))
|
.get(self.url("boards"))
|
||||||
.basic_auth(&self.username, Some(&self.password))
|
.basic_auth(self.username.as_str(), Some(self.password.as_str()))
|
||||||
.header("accept", "application/json")
|
.header("accept", "application/json")
|
||||||
.send()
|
.send()
|
||||||
.await,
|
.await,
|
||||||
|
@ -56,7 +53,7 @@ impl DeckClient {
|
||||||
APIResult::new(
|
APIResult::new(
|
||||||
self.net
|
self.net
|
||||||
.get(self.url(f!("boards/{board_id}")))
|
.get(self.url(f!("boards/{board_id}")))
|
||||||
.basic_auth(&self.username, Some(&self.password))
|
.basic_auth(self.username.as_str(), Some(self.password.as_str()))
|
||||||
.header("accept", "application/json")
|
.header("accept", "application/json")
|
||||||
.send()
|
.send()
|
||||||
.await,
|
.await,
|
||||||
|
@ -68,7 +65,7 @@ impl DeckClient {
|
||||||
APIResult::new(
|
APIResult::new(
|
||||||
self.net
|
self.net
|
||||||
.post(self.url("boards"))
|
.post(self.url("boards"))
|
||||||
.basic_auth(&self.username, Some(&self.password))
|
.basic_auth(self.username.as_str(), Some(self.password.as_str()))
|
||||||
.header("accept", "application/json")
|
.header("accept", "application/json")
|
||||||
.body(
|
.body(
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
|
@ -87,7 +84,7 @@ impl DeckClient {
|
||||||
APIResult::new(
|
APIResult::new(
|
||||||
self.net
|
self.net
|
||||||
.get(self.url(f!("boards/{board_id}/stacks")))
|
.get(self.url(f!("boards/{board_id}/stacks")))
|
||||||
.basic_auth(&self.username, Some(&self.password))
|
.basic_auth(self.username.as_str(), Some(self.password.as_str()))
|
||||||
.header("accept", "application/json")
|
.header("accept", "application/json")
|
||||||
.send()
|
.send()
|
||||||
.await,
|
.await,
|
||||||
|
@ -118,7 +115,7 @@ impl DeckClient {
|
||||||
APIResult::new(
|
APIResult::new(
|
||||||
self.net
|
self.net
|
||||||
.post(&url)
|
.post(&url)
|
||||||
.basic_auth(&self.username, Some(&self.password))
|
.basic_auth(self.username.as_str(), Some(self.password.as_str()))
|
||||||
.header("accept", "application/json")
|
.header("accept", "application/json")
|
||||||
.body(json.to_string())
|
.body(json.to_string())
|
||||||
.send()
|
.send()
|
||||||
|
|
|
@ -17,13 +17,18 @@ mod config {
|
||||||
let username = NextcloudUsername::new("username");
|
let username = NextcloudUsername::new("username");
|
||||||
let password = NextcloudPassword::new("password");
|
let password = NextcloudPassword::new("password");
|
||||||
let board_id = NextcloudBoardId::new(2);
|
let board_id = NextcloudBoardId::new(2);
|
||||||
let cfg = NextcloudConfig::new(hostname.clone(), username, password, board_id);
|
let cfg = NextcloudConfig {
|
||||||
|
hostname: hostname.clone(),
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
board_id,
|
||||||
|
};
|
||||||
|
|
||||||
//when
|
//when
|
||||||
let result = cfg.hostname();
|
let result = cfg.hostname;
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assert_eq!(result, &hostname);
|
assert_eq!(result, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -33,13 +38,18 @@ mod config {
|
||||||
let username = NextcloudUsername::new("username");
|
let username = NextcloudUsername::new("username");
|
||||||
let password = NextcloudPassword::new("password");
|
let password = NextcloudPassword::new("password");
|
||||||
let board_id = NextcloudBoardId::new(2);
|
let board_id = NextcloudBoardId::new(2);
|
||||||
let cfg = NextcloudConfig::new(hostname, username.clone(), password, board_id);
|
let cfg = NextcloudConfig {
|
||||||
|
hostname,
|
||||||
|
username: username.clone(),
|
||||||
|
password,
|
||||||
|
board_id,
|
||||||
|
};
|
||||||
|
|
||||||
//when
|
//when
|
||||||
let result = cfg.username();
|
let result = cfg.username;
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assert_eq!(result, &username);
|
assert_eq!(result, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -49,13 +59,18 @@ mod config {
|
||||||
let username = NextcloudUsername::new("username");
|
let username = NextcloudUsername::new("username");
|
||||||
let password = NextcloudPassword::new("password");
|
let password = NextcloudPassword::new("password");
|
||||||
let board_id = NextcloudBoardId::new(2);
|
let board_id = NextcloudBoardId::new(2);
|
||||||
let cfg = NextcloudConfig::new(hostname, username, password.clone(), board_id);
|
let cfg = NextcloudConfig {
|
||||||
|
hostname,
|
||||||
|
username,
|
||||||
|
password: password.clone(),
|
||||||
|
board_id,
|
||||||
|
};
|
||||||
|
|
||||||
//when
|
//when
|
||||||
let result = cfg.password();
|
let result = cfg.password;
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assert_eq!(result, &password);
|
assert_eq!(result, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -65,10 +80,15 @@ mod config {
|
||||||
let username = NextcloudUsername::new("username");
|
let username = NextcloudUsername::new("username");
|
||||||
let password = NextcloudPassword::new("password");
|
let password = NextcloudPassword::new("password");
|
||||||
let board_id = NextcloudBoardId::new(2);
|
let board_id = NextcloudBoardId::new(2);
|
||||||
let cfg = NextcloudConfig::new(hostname, username, password, board_id);
|
let cfg = NextcloudConfig {
|
||||||
|
hostname,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
board_id,
|
||||||
|
};
|
||||||
|
|
||||||
//when
|
//when
|
||||||
let result = cfg.board_id();
|
let result = cfg.board_id;
|
||||||
|
|
||||||
//then
|
//then
|
||||||
assert_eq!(result, board_id);
|
assert_eq!(result, board_id);
|
||||||
|
@ -174,7 +194,7 @@ mod client {
|
||||||
|
|
||||||
//when
|
//when
|
||||||
let result = deck_client
|
let result = deck_client
|
||||||
.get_stacks(cfg.board_id())
|
.get_stacks(cfg.board_id)
|
||||||
.await
|
.await
|
||||||
.result
|
.result
|
||||||
.expect("get stacks");
|
.expect("get stacks");
|
||||||
|
@ -216,6 +236,11 @@ mod given {
|
||||||
let username = NextcloudUsername::new("username");
|
let username = NextcloudUsername::new("username");
|
||||||
let password = NextcloudPassword::new("password");
|
let password = NextcloudPassword::new("password");
|
||||||
let board_id = NextcloudBoardId::new(2);
|
let board_id = NextcloudBoardId::new(2);
|
||||||
NextcloudConfig::new(hostname, username, password, board_id)
|
NextcloudConfig {
|
||||||
|
hostname,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
board_id,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,48 @@ mod init {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod config {
|
||||||
|
use super::*;
|
||||||
|
mod load {
|
||||||
|
use super::*;
|
||||||
|
use crate::config::{NextcloudConfig, TrelloConfig};
|
||||||
|
use crate::{s, AppConfig};
|
||||||
|
#[test]
|
||||||
|
fn test_load() {
|
||||||
|
//given
|
||||||
|
let fs = given::a_filesystem();
|
||||||
|
let mock_net = given::a_network();
|
||||||
|
|
||||||
|
let file = fs.file(&fs.base().join("trello-to-deck.toml"));
|
||||||
|
file.write(include_str!("test-config.toml"))
|
||||||
|
.expect("write test config");
|
||||||
|
|
||||||
|
let ctx = given::a_context(fs.as_real(), mock_net.into());
|
||||||
|
|
||||||
|
//when
|
||||||
|
let cfg = AppConfig::load(&ctx);
|
||||||
|
|
||||||
|
//then
|
||||||
|
let_assert!(Ok(cfg) = cfg);
|
||||||
|
assert_eq!(
|
||||||
|
cfg,
|
||||||
|
AppConfig {
|
||||||
|
trello: TrelloConfig {
|
||||||
|
api_key: s!("trello-api-key").into(),
|
||||||
|
api_secret: s!("trello-api-secret").into(),
|
||||||
|
board_name: s!("trello-board-name").into(),
|
||||||
|
},
|
||||||
|
nextcloud: NextcloudConfig {
|
||||||
|
hostname: s!("nextcloud-hostname").into(),
|
||||||
|
username: s!("nextcloud-username").into(),
|
||||||
|
password: s!("nextcloud-password").into(),
|
||||||
|
board_id: 321.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
mod template {
|
mod template {
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
10
src/tests/test-config.toml
Normal file
10
src/tests/test-config.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[trello]
|
||||||
|
api_key = "trello-api-key"
|
||||||
|
api_secret = "trello-api-secret"
|
||||||
|
board_name = "trello-board-name"
|
||||||
|
|
||||||
|
[nextcloud]
|
||||||
|
hostname = "nextcloud-hostname"
|
||||||
|
username = "nextcloud-username"
|
||||||
|
password = "nextcloud-password"
|
||||||
|
board_id = 321
|
|
@ -1,14 +1,14 @@
|
||||||
//
|
//
|
||||||
pub mod api;
|
// pub mod api;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
#[cfg(test)]
|
// #[cfg(test)]
|
||||||
mod tests;
|
// mod tests;
|
||||||
|
|
||||||
use crate::f;
|
// use crate::f;
|
||||||
|
//
|
||||||
pub fn url(path: impl Into<String>) -> String {
|
// pub fn url(path: impl Into<String>) -> String {
|
||||||
let path = path.into();
|
// let path = path.into();
|
||||||
assert!(path.starts_with("/"));
|
// assert!(path.starts_with("/"));
|
||||||
f!("https://api.trello.com/1{path}")
|
// f!("https://api.trello.com/1{path}")
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
|
//
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
//
|
|
||||||
use derive_more::derive::Display;
|
use derive_more::derive::Display;
|
||||||
|
|
||||||
use crate::newtype;
|
use crate::newtype;
|
||||||
|
|
||||||
newtype!(TrelloUser, String, Display, "User");
|
newtype!(TrelloApiKey, String, Display, PartialOrd, Ord, "API Key");
|
||||||
newtype!(TrelloApiKey, String, Display, "API Key");
|
|
||||||
newtype!(
|
newtype!(
|
||||||
TrelloApiSecret,
|
TrelloApiSecret,
|
||||||
String,
|
String,
|
||||||
Display,
|
Display,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
"API Secret token for Trello"
|
"API Secret token for Trello"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,14 +19,12 @@ newtype!(
|
||||||
pub struct TrelloAuth {
|
pub struct TrelloAuth {
|
||||||
api_key: TrelloApiKey,
|
api_key: TrelloApiKey,
|
||||||
api_secret: TrelloApiSecret,
|
api_secret: TrelloApiSecret,
|
||||||
user: TrelloUser,
|
|
||||||
}
|
}
|
||||||
impl TrelloAuth {
|
impl TrelloAuth {
|
||||||
pub const fn new(api_key: TrelloApiKey, api_secret: TrelloApiSecret, user: TrelloUser) -> Self {
|
pub const fn new(api_key: TrelloApiKey, api_secret: TrelloApiSecret) -> Self {
|
||||||
Self {
|
Self {
|
||||||
api_key,
|
api_key,
|
||||||
api_secret,
|
api_secret,
|
||||||
user,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +34,6 @@ impl TrelloAuth {
|
||||||
pub const fn api_token(&self) -> &TrelloApiSecret {
|
pub const fn api_token(&self) -> &TrelloApiSecret {
|
||||||
&self.api_secret
|
&self.api_secret
|
||||||
}
|
}
|
||||||
pub const fn user(&self) -> &TrelloUser {
|
|
||||||
&self.user
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl From<&TrelloAuth> for HashMap<String, String> {
|
impl From<&TrelloAuth> for HashMap<String, String> {
|
||||||
fn from(value: &TrelloAuth) -> Self {
|
fn from(value: &TrelloAuth) -> Self {
|
||||||
|
|
|
@ -1,23 +1,30 @@
|
||||||
pub(crate) mod auth;
|
pub(crate) mod auth;
|
||||||
pub(crate) mod board;
|
// pub(crate) mod board;
|
||||||
// mod card;
|
// mod card;
|
||||||
mod list;
|
// mod list;
|
||||||
// mod new_card;
|
// mod new_card;
|
||||||
|
|
||||||
use derive_more::derive::Display;
|
use derive_more::derive::Display;
|
||||||
|
|
||||||
use crate::newtype;
|
use crate::newtype;
|
||||||
|
|
||||||
newtype!(TrelloBoardId, String, Display, "Board ID");
|
// newtype!(TrelloBoardId, String, Display, "Board ID");
|
||||||
newtype!(TrelloBoardName, String, Display, "Board Name");
|
|
||||||
newtype!(TrelloListId, String, "List ID");
|
|
||||||
newtype!(
|
newtype!(
|
||||||
TrelloListName,
|
TrelloBoardName,
|
||||||
String,
|
String,
|
||||||
Display,
|
Display,
|
||||||
PartialOrd,
|
PartialOrd,
|
||||||
Ord,
|
Ord,
|
||||||
"List Name"
|
"Board Name"
|
||||||
);
|
);
|
||||||
newtype!(TrelloCardId, String, Display, "Card ID");
|
// newtype!(TrelloListId, String, "List ID");
|
||||||
newtype!(TrelloCardName, String, Display, "Card Name");
|
// newtype!(
|
||||||
|
// TrelloListName,
|
||||||
|
// String,
|
||||||
|
// Display,
|
||||||
|
// PartialOrd,
|
||||||
|
// Ord,
|
||||||
|
// "List Name"
|
||||||
|
// );
|
||||||
|
// newtype!(TrelloCardId, String, Display, "Card ID");
|
||||||
|
// newtype!(TrelloCardName, String, Display, "Card Name");
|
||||||
|
|
Loading…
Reference in a new issue