Added --sort.
This commit is contained in:
parent
8ec8a1a558
commit
b7332de342
|
@ -39,6 +39,9 @@ Only export entries between _start_ and _end_. _start_ and _end_ are date and
|
|||
time representations according to ISO 8601. Time zones are ignored at the
|
||||
moment.
|
||||
|
||||
*-S* _attribute_, *--sort* _attribute_::
|
||||
Sort by _time_, _tag_ or _both_ (default) when exporting to _asciidoc_.
|
||||
|
||||
*-h*, *--help*::
|
||||
Show help message.
|
||||
|
||||
|
@ -55,7 +58,7 @@ Print version, copyright and license.
|
|||
|
||||
== FILES
|
||||
|
||||
* *Database*: `${XDG_DATA_HOME}/remwharead.sqlite`
|
||||
* *Database*: `${XDG_DATA_HOME}/remwharead/database.sqlite`
|
||||
|
||||
`${XDG_DATA_HOME}` is usually `~/.local/share`.
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ const options parse_options(const int argc, const char *argv[])
|
|||
string format;
|
||||
string file;
|
||||
string span;
|
||||
string sort;
|
||||
options opts;
|
||||
|
||||
try
|
||||
|
@ -51,6 +52,8 @@ const options parse_options(const int argc, const char *argv[])
|
|||
op.add<popl::Value<string>>
|
||||
("s", "span", "Only export entries between YYYY-MM-DD,YYYY-MM-DD.",
|
||||
"", &span);
|
||||
op.add<popl::Value<string>>
|
||||
("S", "sort", "Sort by time, tag or both (default).", "", &sort);
|
||||
auto option_help = op.add<popl::Switch>
|
||||
("h", "help", "Show this help message.");
|
||||
auto option_version = op.add<popl::Switch>
|
||||
|
@ -129,6 +132,27 @@ const options parse_options(const int argc, const char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (!sort.empty())
|
||||
{
|
||||
if (sort == "time")
|
||||
{
|
||||
opts.sort = sort_attribute::time;
|
||||
}
|
||||
else if (sort == "tag")
|
||||
{
|
||||
opts.sort = sort_attribute::tag;
|
||||
}
|
||||
else if (sort == "both")
|
||||
{
|
||||
opts.sort = sort_attribute::both;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Error: --sort " << sort << " not understood.\n";
|
||||
return options(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (op.non_option_args().size() > 0)
|
||||
{
|
||||
opts.url = op.non_option_args().front();
|
||||
|
|
|
@ -37,12 +37,20 @@ enum class export_format
|
|||
asciidoc
|
||||
};
|
||||
|
||||
enum class sort_attribute
|
||||
{
|
||||
both,
|
||||
time,
|
||||
tag
|
||||
};
|
||||
|
||||
typedef struct options
|
||||
{
|
||||
vector<string> tags;
|
||||
export_format format = export_format::undefined;
|
||||
string file;
|
||||
array<system_clock::time_point, 2> span;
|
||||
sort_attribute sort = sort_attribute::both;
|
||||
string url;
|
||||
uint8_t status_code = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue