use static strings for usage

This commit is contained in:
Dustin J. Mitchell
2020-12-24 21:07:27 +00:00
parent 7594144a2d
commit 75aaf8d4ab
7 changed files with 138 additions and 141 deletions

View File

@@ -2,7 +2,6 @@ use super::args::{arg_matching, id_list, minus_tag, plus_tag, TaskId};
use super::ArgList;
use crate::usage;
use nom::{branch::alt, combinator::*, multi::fold_many0, IResult};
use textwrap::dedent;
/// A filter represents a selection of a particular set of tasks.
///
@@ -115,31 +114,25 @@ impl Filter {
pub(super) fn get_usage(u: &mut usage::Usage) {
u.filters.push(usage::Filter {
syntax: "TASKID[,TASKID,..]".to_owned(),
summary: "Specific tasks".to_owned(),
description: dedent(
"
syntax: "TASKID[,TASKID,..]",
summary: "Specific tasks",
description: "
Select only specific tasks. Multiple tasks can be specified either separated by
commas or as separate arguments. Each task may be specfied by its working-set
index (a small number) or by its UUID. Prefixes of UUIDs broken at hyphens are
index (a small number) or by its UUID. Partial UUIDs, broken on a hyphen, are
also supported, such as `b5664ef8-423d` or `b5664ef8`.",
),
});
u.filters.push(usage::Filter {
syntax: "+TAG".to_owned(),
summary: "Tagged tasks".to_owned(),
description: dedent(
"
syntax: "+TAG",
summary: "Tagged tasks",
description: "
Select tasks with the given tag.",
),
});
u.filters.push(usage::Filter {
syntax: "-TAG".to_owned(),
summary: "Un-tagged tasks".to_owned(),
description: dedent(
"
syntax: "-TAG",
summary: "Un-tagged tasks",
description: "
Select tasks that do not have the given tag.",
),
});
}
}

View File

@@ -4,7 +4,6 @@ use crate::usage;
use nom::{branch::alt, combinator::*, multi::fold_many0, IResult};
use std::collections::HashSet;
use taskchampion::Status;
use textwrap::dedent;
#[derive(Debug, PartialEq, Clone)]
pub enum DescriptionMod {
@@ -112,29 +111,23 @@ impl Modification {
pub(super) fn get_usage(u: &mut usage::Usage) {
u.modifications.push(usage::Modification {
syntax: "DESCRIPTION".to_owned(),
summary: "Set description".to_owned(),
description: dedent(
"
syntax: "DESCRIPTION",
summary: "Set description",
description: "
Set the task description. Multiple arguments are combined into a single
space-separated description.",
),
});
u.modifications.push(usage::Modification {
syntax: "+TAG".to_owned(),
summary: "Tag task".to_owned(),
description: dedent(
"
syntax: "+TAG",
summary: "Tag task",
description: "
Add the given tag to the task.",
),
});
u.modifications.push(usage::Modification {
syntax: "-TAG".to_owned(),
summary: "Un-tag task".to_owned(),
description: dedent(
"
syntax: "-TAG",
summary: "Un-tag task",
description: "
Remove the given tag from the task.",
),
});
}
}

View File

@@ -3,7 +3,6 @@ use super::{ArgList, DescriptionMod, Filter, Modification, Report};
use crate::usage;
use nom::{branch::alt, combinator::*, sequence::*, IResult};
use taskchampion::Status;
use textwrap::dedent;
// IMPLEMENTATION NOTE:
//
@@ -97,10 +96,10 @@ impl Version {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "version".to_owned(),
syntax: "version".to_owned(),
summary: "Show the TaskChampion version".to_owned(),
description: "Show the version of the TaskChampion binary".to_owned(),
name: "version",
syntax: "version",
summary: "Show the TaskChampion version",
description: "Show the version of the TaskChampion binary",
});
}
}
@@ -144,14 +143,12 @@ impl Add {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "add".to_owned(),
syntax: "add [modification]".to_owned(),
summary: "Add a new task".to_owned(),
description: dedent(
"
name: "add",
syntax: "add [modification]",
summary: "Add a new task",
description: "
Add a new, pending task to the list of tasks. The modification must include a
description.",
),
});
}
}
@@ -205,60 +202,49 @@ impl Modify {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "modify".to_owned(),
syntax: "[filter] modify [modification]".to_owned(),
summary: "Modify tasks".to_owned(),
description: dedent(
"
name: "modify",
syntax: "[filter] modify [modification]",
summary: "Modify tasks",
description: "
Modify all tasks matching the filter.",
),
});
u.subcommands.push(usage::Subcommand {
name: "prepend".to_owned(),
syntax: "[filter] prepend [modification]".to_owned(),
summary: "Prepend task description".to_owned(),
description: dedent(
"
name: "prepend",
syntax: "[filter] prepend [modification]",
summary: "Prepend task description",
description: "
Modify all tasks matching the filter by inserting the given description before each
task's description.",
),
});
u.subcommands.push(usage::Subcommand {
name: "append".to_owned(),
syntax: "[filter] append [modification]".to_owned(),
summary: "Append task description".to_owned(),
description: dedent(
"
name: "append",
syntax: "[filter] append [modification]",
summary: "Append task description",
description: "
Modify all tasks matching the filter by adding the given description to the end
of each task's description.",
),
});
u.subcommands.push(usage::Subcommand {
name: "start".to_owned(),
syntax: "[filter] start [modification]".to_owned(),
summary: "Start tasks".to_owned(),
description: dedent(
"
Start all tasks matching the filter, additionally applying any given modifications."),
name: "start",
syntax: "[filter] start [modification]",
summary: "Start tasks",
description: "
Start all tasks matching the filter, additionally applying any given modifications."
});
u.subcommands.push(usage::Subcommand {
name: "stop".to_owned(),
syntax: "[filter] stop [modification]".to_owned(),
summary: "Stop tasks".to_owned(),
description: dedent(
"
name: "stop",
syntax: "[filter] stop [modification]",
summary: "Stop tasks",
description: "
Stop all tasks matching the filter, additionally applying any given modifications.",
),
});
u.subcommands.push(usage::Subcommand {
name: "done".to_owned(),
syntax: "[filter] done [modification]".to_owned(),
summary: "Mark tasks as completed".to_owned(),
description: dedent(
"
name: "done",
syntax: "[filter] done [modification]",
summary: "Mark tasks as completed",
description: "
Mark all tasks matching the filter as completed, additionally applying any given
modifications.",
),
});
}
}
@@ -278,13 +264,11 @@ impl List {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "list".to_owned(),
syntax: "[filter] list".to_owned(),
summary: "List tasks".to_owned(),
description: dedent(
"
name: "list",
syntax: "[filter] list",
summary: "List tasks",
description: "
Show a list of the tasks matching the filter",
),
});
}
}
@@ -314,22 +298,16 @@ impl Info {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "info".to_owned(),
syntax: "[filter] info".to_owned(),
summary: "Show tasks".to_owned(),
description: dedent(
"
Show information about all tasks matching the fiter.",
),
name: "info",
syntax: "[filter] info",
summary: "Show tasks",
description: " Show information about all tasks matching the fiter.",
});
u.subcommands.push(usage::Subcommand {
name: "debug".to_owned(),
syntax: "[filter] debug".to_owned(),
summary: "Show task debug details".to_owned(),
description: dedent(
"
Show all key/value properties of the tasks matching the fiter.",
),
name: "debug",
syntax: "[filter] debug",
summary: "Show task debug details",
description: " Show all key/value properties of the tasks matching the fiter.",
});
}
}
@@ -346,14 +324,12 @@ impl Gc {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "gc".to_owned(),
syntax: "gc".to_owned(),
summary: "Perform 'garbage collection'".to_owned(),
description: dedent(
"
name: "gc",
syntax: "gc",
summary: "Perform 'garbage collection'",
description: "
Perform 'garbage collection'. This refreshes the list of pending tasks
and their short id's.",
),
});
}
}
@@ -370,16 +346,14 @@ impl Sync {
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "sync".to_owned(),
syntax: "sync".to_owned(),
summary: "Synchronize this replica".to_owned(),
description: dedent(
"
name: "sync",
syntax: "sync",
summary: "Synchronize this replica",
description: "
Synchronize this replica locally or against a remote server, as configured.
Synchronization is a critical part of maintaining the task database, and should
be done regularly, even if only locally. It is typically run in a crontask.",
),
})
}
}