jp (blog/edit): added --no-publish argument.

This commit is contained in:
Goffi 2020-02-18 18:17:18 +01:00
commit 3d8ef1d625
2 changed files with 12 additions and 5 deletions

View file

@ -76,11 +76,11 @@ the *metadata*. You can also specify editor and arguments in ``sat.conf``, see
If you don't change anything or publish an empty blog post, the edition will be cancelled. If you don't change anything or publish an empty blog post, the edition will be cancelled.
In the metadata (see `below <edit_metadata_>`_ for details), you can use In the metadata (see `below <edit_metadata_>`_ for details), you can use ``"publish":
``"publish": false`` to forbid the publication. In this case, when you'll save false`` to forbid the publication (or set it with ``--no-publish argument``). In this
your modification and quit your editor, the blog post will not be published but case, when you'll save your modification and quit your editor, the blog post will not be
saved locally in a draft. To continue your work later, just start your edition with the published but saved locally in a draft. To continue your work later, just start your
``-D, --current`` option like this:: edition with the ``-D, --current`` option like this::
$ jp blog edit -D $ jp blog edit -D

View file

@ -466,6 +466,10 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
action="store_true", action="store_true",
help=_("launch a blog preview in parallel"), help=_("launch a blog preview in parallel"),
) )
self.parser.add_argument(
"--no-publish",
help=_('add "publish: False" to metadata'),
)
def buildMetadataFile(self, content_file_path, mb_data=None): def buildMetadataFile(self, content_file_path, mb_data=None):
"""Build a metadata file using json """Build a metadata file using json
@ -506,6 +510,9 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
# and override metadata with command-line arguments # and override metadata with command-line arguments
self.setMbDataFromArgs(mb_data) self.setMbDataFromArgs(mb_data)
if self.args.no_publish is not None:
mb_data["publish"] = False
# then we create the file and write metadata there, as JSON dict # then we create the file and write metadata there, as JSON dict
# XXX: if we port jp one day on Windows, O_BINARY may need to be added here # XXX: if we port jp one day on Windows, O_BINARY may need to be added here
with os.fdopen( with os.fdopen(