Expand description
Minimal example using tasklib
.
use tasklib::prelude::*;
let json = r#"
{
"id": 0,
"description": "Task to do.",
"end": "20220131T083000Z",
"entry": "20220131T083000Z",
"modified": "20220131T083000Z",
"project": "Daily",
"start": "20220131T083000Z",
"status": "pending",
"uuid": "d67fce70-c0b6-43c5-affc-a21e64567d40",
"tags": [
"WORK"
],
"urgency": 9.91234
}"#;
// Getting a Task from your input JSON string.
let task: Task = Task::from(json);
// Getting a String from your Serialized Task
let task_str: String = task.into();
Example getting task from stdin and writing to stdout.
ⓘ
use tasklib::prelude::*;
// Getting a Task from stdin
let task: Task = Task::from_stdin().expect("read task from stdin as JSON");
// Writing a Task to stdout, as JSON
task.to_stdout().expect("write task to stdout as JSON");
Example getting command line arguments.
use std::env;
use tasklib::prelude::*;
// Get the command line arguments.
let args: CliArguments = CliArguments::from(env::args());
args.hook(); // PathBuf::from("/home/.task/hooks/on-add.tsk")
args.api_version(); // ApiVersion::V2
args.arguments(); // String::from("task add Task to do.")
args.command(); // Command::Add
args.rc_file(); // PathBuf::from("/home/.taskrc")
args.data_location(); // PathBuf::from("/home/.task")
args.task_version(); // "2.6.3"
Modules§
Structs§
- See all columns using
task columns
andtask _columns
.