diff --git a/opustags.1 b/opustags.1 index 4403abb..229b698 100644 --- a/opustags.1 +++ b/opustags.1 @@ -52,7 +52,7 @@ The input file will be read, its tags edited, then written to the specified outp \fIFILE\fP is \fB-\fP then the resulting Opus file will be written to standard output. The output file can’t be the same as the input file. .TP -.B \-i, \-\-in-place \fR[\fP\fISUFFIX\fP\fR]\fP +.B \-i, \-\-in-place\fR[=\fP\fISUFFIX\fP\fR]\fP Use this when you want to modify the input file in-place. opustags will create a temporary output file with the specified suffix (.otmp by default), and move it to the location of the input file on success. If a file with the same name as the temporary file already exists, it will be overwritten diff --git a/src/cli.cc b/src/cli.cc index 71de541..f48daa9 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -4,6 +4,9 @@ * * Provide all the features of the opustags executable from a C++ API. The main point of separating * this module from the main one is to allow easy testing. + * + * \todo Use a safer temporary file name for in-place editing, like tmpnam. + * \todo Abort editing with --set-all if one comment is invalid? */ #include @@ -25,14 +28,14 @@ Usage: opustags --help static const char* help = 1 + R"raw( Options: -h, --help print this help - -o, --output write the modified tags to a file - -i, --in-place [SUFFIX] use a temporary file then replace the original file + -o, --output FILE set the output file + -i, --in-place overwrite the input file instead of writing a different output file -y, --overwrite overwrite the output file if it already exists - -d, --delete FIELD delete all the fields of a specified type - -a, --add FIELD=VALUE add a field - -s, --set FIELD=VALUE delete then add a field - -D, --delete-all delete all the fields! - -S, --set-all read the fields from stdin + -a, --add FIELD=VALUE add a comment + -d, --delete FIELD delete all previously existing comments of a specific type + -D, --delete-all delete all the previously existing comments + -s, --set FIELD=VALUE replace a comment (shorthand for --delete FIELD --add FIELD=VALUE) + -S, --set-all replace all the comments with the ones read from standard input )raw"; static struct option getopt_options[] = { @@ -130,11 +133,11 @@ ot::status ot::process_options(int argc, char** argv, ot::options& opt) opt.path_out = opt.path_in + opt.inplace; } if (opt.path_in == "-" && opt.set_all) { - fputs("can't open stdin for input when -S is specified\n", stderr); + fputs("can't open standard input for input when --set-all is specified\n", stderr); return st::bad_arguments; } if (opt.path_in == "-" && opt.inplace) { - fputs("cannot modify stdin in-place\n", stderr); + fputs("cannot modify standard input in-place\n", stderr); return st::bad_arguments; } return st::ok; diff --git a/t/opustags.t b/t/opustags.t index 5ffbf9b..4b8613d 100644 --- a/t/opustags.t +++ b/t/opustags.t @@ -57,14 +57,14 @@ Usage: opustags --help Options: -h, --help print this help - -o, --output write the modified tags to a file - -i, --in-place [SUFFIX] use a temporary file then replace the original file + -o, --output FILE set the output file + -i, --in-place overwrite the input file instead of writing a different output file -y, --overwrite overwrite the output file if it already exists - -d, --delete FIELD delete all the fields of a specified type - -a, --add FIELD=VALUE add a field - -s, --set FIELD=VALUE delete then add a field - -D, --delete-all delete all the fields! - -S, --set-all read the fields from stdin + -a, --add FIELD=VALUE add a comment + -d, --delete FIELD delete all previously existing comments of a specific type + -D, --delete-all delete all the previously existing comments + -s, --set FIELD=VALUE replace a comment (shorthand for --delete FIELD --add FIELD=VALUE) + -S, --set-all replace all the comments with the ones read from standard input See the man page for extensive documentation. EOF