T3JC4SZWKROQ4NL3MRBNVMTWLOOHN2UPIEY6XCBVI3WAWLWDBVOAC #[tokio::main]async fn main() {let config = config::Config::parse();let toggl = Toggl::new(config.credentials.clone()).unwrap();let (user_info, _) = toggl.user_info(None).await.unwrap();println!("User info\n---------\n{:?}", &user_info);let projects = toggl.projects_of_workspace(&user_info.workspaces[0]).await.unwrap();println!("Projects: {:?}", projects);
fn main() {println!("Hello, world!");
let time_entries = toggl.time_entries(Utc::now() - chrono::Duration::days(1),Utc::now() + chrono::Duration::days(1),).await.unwrap();println!("Entries: {:?}", time_entries);let mut last_ts = None;loop {let (data, ts) = toggl.all_data(last_ts).await.unwrap();last_ts = Some(ts);println!("{:?}", data);tokio::time::sleep(chrono::Duration::seconds(5).to_std().unwrap()).await;}
use clap::{App, Arg, ArgGroup};use toggl_api::Credentials;pub(crate) struct Config {pub(crate) credentials: Credentials,}impl Config {pub(crate) fn parse() -> Self {let app = App::new(clap::crate_name!()).version(clap::crate_version!()).arg(Arg::new("api-token").long("api-token").env("TOGGL_API_TOKEN").value_name("TOKEN").conflicts_with("password").takes_value(true),).arg(Arg::new("username").long("username").value_name("USERNAME").requires("password").takes_value(true),).arg(Arg::new("password").long("password").value_name("PASSWORD").takes_value(true),).group(ArgGroup::new("user-id").required(true).args(&["api-token", "username"]),);let matches = app.get_matches();let credentials = if let Some(api_token) = matches.value_of("api-token") {Credentials::ApiToken(api_token.to_string())} else {let username = matches.value_of("username").unwrap().to_string();let password = matches.value_of("password").unwrap().to_string();Credentials::Password { username, password }};Self { credentials }}}
diesel = { version = "2.0", features = ["sqlite", "chrono"], git = "https://github.com/diesel-rs/diesel" }
clap = "3.0.0-beta"diesel = { version = "2.0", features = ["sqlite", "chrono"], git = "https://github.com/diesel-rs/diesel" }toggl-api = { path = "../toggl-api" }tokio = { version = "1.14", features = ["full"] }
][[package]]name = "clap"version = "3.0.0-beta.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63"dependencies = ["atty","bitflags","clap_derive","indexmap","lazy_static","os_str_bytes","strsim","termcolor","textwrap","unicase",][[package]]name = "clap_derive"version = "3.0.0-beta.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8b15c6b4f786ffb6192ffe65a36855bc1fc2444bcd0945ae16748dcd6ed7d0d3"dependencies = ["heck","proc-macro-error","proc-macro2","quote","syn",
[[package]]name = "heck"version = "0.3.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"dependencies = ["unicode-segmentation",][[package]]name = "hermit-abi"version = "0.1.19"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"dependencies = ["libc",]
name = "os_str_bytes"version = "4.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799"dependencies = ["memchr",][[package]]name = "parking_lot"version = "0.11.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"dependencies = ["instant","lock_api","parking_lot_core",][[package]]name = "parking_lot_core"version = "0.8.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"dependencies = ["cfg-if","instant","libc","redox_syscall","smallvec","winapi",][[package]]
[[package]]name = "proc-macro-error"version = "1.0.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"dependencies = ["proc-macro-error-attr","proc-macro2","quote","syn","version_check",][[package]]name = "proc-macro-error-attr"version = "1.0.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"dependencies = ["proc-macro2","quote","version_check",]
[[package]]name = "unicode-segmentation"version = "1.8.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"[[package]]name = "unicode-width"version = "0.1.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"