diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2023-02-07 14:24:37 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2023-02-07 14:24:37 +0000 |
| commit | b688602d12a0d7f446f5924d5ec3cd12ed2f7927 (patch) | |
| tree | e321b97b7f345bfdae24e0bc0fae9f90677b1cec /docutils | |
| parent | 6177e6b7592b7fe1b3db1b1b8a1ff0b8e595319f (diff) | |
| download | docutils-b688602d12a0d7f446f5924d5ec3cd12ed2f7927.tar.gz | |
New general setting "output".
This setting obsoletes the positional argument <destination>.
Cf. the announcement of command line pattern changes in the
RELEASE-NOTES.
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk/docutils@9328 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/core.py | 15 | ||||
| -rw-r--r-- | docutils/frontend.py | 7 |
2 files changed, 16 insertions, 6 deletions
diff --git a/docutils/core.py b/docutils/core.py index d9b62860c..b369a9cfe 100644 --- a/docutils/core.py +++ b/docutils/core.py @@ -192,9 +192,16 @@ class Publisher: def set_destination(self, destination=None, destination_path=None): if destination_path is None: - destination_path = self.settings._destination - else: - self.settings._destination = destination_path + if (self.settings.output and self.settings._destination + and self.settings.output != self.settings._destination): + raise SystemExit('The positional argument <destination> is ' + 'obsoleted by the --output option. ' + 'You cannot use them together.') + if self.settings.output == '-': # means stdout + self.settings.output = None + destination_path = (self.settings.output + or self.settings._destination) + self.settings._destination = destination_path self.destination = self.destination_class( destination=destination, destination_path=destination_path, encoding=self.settings.output_encoding, @@ -362,8 +369,8 @@ default_description = ( # TODO: or not to do? cf. https://clig.dev/#help # # Display output on success, but keep it brief. -# # Provide a -q option to suppress all non-essential output. +# # Chain several args as input and use --output or redirection for output: # argparser.add_argument('source', nargs='+') # diff --git a/docutils/frontend.py b/docutils/frontend.py index 62769aa30..e9a2e25bc 100644 --- a/docutils/frontend.py +++ b/docutils/frontend.py @@ -461,8 +461,11 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): settings_spec = ( 'General Docutils Options', None, - (('Specify the document title as metadata.', - ['--title'], {}), + (('Output destination name. Obsoletes the <destination> ' + 'positional argument. Default: None (stdout).', + ['--output'], {'metavar': '<destination>'}), + ('Specify the document title as metadata.', + ['--title'], {'metavar': '<title>'}), ('Include a "Generated by Docutils" credit and link.', ['--generator', '-g'], {'action': 'store_true', 'validator': validate_boolean}), |
