mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
take configuration in env vars temporarily
This commit is contained in:
parent
97a8a87c24
commit
1a92613ddc
3 changed files with 25 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
use clap::Arg;
|
||||
use failure::{format_err, Fallible};
|
||||
use std::path::Path;
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use taskchampion::{server, taskstorage, Replica, Task, Uuid};
|
||||
|
||||
pub(super) fn task_arg<'a>() -> Arg<'a, 'a> {
|
||||
|
@ -46,14 +47,18 @@ impl CommandInvocation {
|
|||
// -- utilities for command invocations
|
||||
|
||||
pub(super) fn get_replica(&self) -> Replica {
|
||||
Replica::new(Box::new(
|
||||
taskstorage::KVStorage::new(Path::new("/tmp/tasks")).unwrap(),
|
||||
))
|
||||
// temporarily use $TASK_DB to locate the taskdb
|
||||
let taskdb_dir = env::var_os("TASK_DB").unwrap_or_else(|| OsString::from("/tmp/tasks"));
|
||||
Replica::new(Box::new(taskstorage::KVStorage::new(taskdb_dir).unwrap()))
|
||||
}
|
||||
|
||||
pub(super) fn get_server(&self) -> Fallible<impl server::Server> {
|
||||
// temporarily use $SYNC_SERVER_ORIGIN for the sync server
|
||||
let sync_server_origin = env::var_os("SYNC_SERVER_ORIGIN")
|
||||
.map(|osstr| osstr.into_string().unwrap())
|
||||
.unwrap_or_else(|| String::from("http://localhost:8080"));
|
||||
Ok(server::RemoteServer::new(
|
||||
"http://localhost:8080".into(),
|
||||
sync_server_origin,
|
||||
Uuid::parse_str("d5b55cbd-9a82-4860-9a39-41b67893b22f").unwrap(),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
# Usage
|
||||
|
||||
## `task`
|
||||
|
||||
The main interface to your tasks is the `task` command, which supports various subcommands.
|
||||
You can find a quick list of all subcommands with `task help`.
|
||||
|
||||
Note that the `task` interface does not match that of TaskWarrior.
|
||||
|
||||
### Configuration
|
||||
|
||||
Temporarily, configuration is by environment variables.
|
||||
The directory containing the replica's task data is given by `TASK_DB`, defaulting to `/tmp/tasks`.
|
||||
the origin of the sync server is given by `SYNC_SERVER_ORIGIN`, defaulting to `http://localhost:8080`.
|
||||
|
||||
## `taskchampion-sync-server`
|
||||
|
||||
Run `taskchampion-sync-server` to start the sync server.
|
||||
It serves on port 8080 on all interfaces, using an in-memory database (meaning that all data is lost when the process exits).
|
||||
Requests for previously-unknown clients are automatically added.
|
||||
|
|
|
@ -23,7 +23,7 @@ const NEXT_OPERATION: u64 = 2;
|
|||
const NEXT_WORKING_SET_INDEX: u64 = 3;
|
||||
|
||||
impl<'t> KVStorage<'t> {
|
||||
pub fn new(directory: &Path) -> Fallible<KVStorage> {
|
||||
pub fn new<P: AsRef<Path>>(directory: P) -> Fallible<KVStorage<'t>> {
|
||||
let mut config = Config::default(directory);
|
||||
config.bucket("tasks", None);
|
||||
config.bucket("numbers", None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue