Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'title' command. #203

Merged
merged 3 commits into from May 2, 2016
Merged

Add 'title' command. #203

merged 3 commits into from May 2, 2016

Conversation

tohojo
Copy link
Contributor

@tohojo tohojo commented Apr 27, 2016

I found myself wanting a quick way to add simple titles to lots of images. Rather than writing a separate script I thought that just adding a new command to sigal itself might be easier. Do you think this is worth including in upstream sigal? In that case I can add test cases and documentation for it, but wanted to see if you'd want to take it at all first...

This adds a 'title' command to make it easier to add titles to images.
It basically takes an image filename and a title, and will write a
corresponding .md file with the Title attribute.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
@saimn
Copy link
Owner

saimn commented Apr 28, 2016

It can be useful so +1 but maybe a bit more generic, to allow writing several key/value pairs at once ? Then we also need a more generic name ;)

@main.command()
@argument('image')
@argument('title')
@option('-f', '--force', default=False, is_flag=True,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer overwrite to force, more explicit on what it does.

@saimn
Copy link
Owner

saimn commented Apr 28, 2016

It could be useful for albums as well.

@tohojo
Copy link
Contributor Author

tohojo commented May 1, 2016

Something like this?

@option('-o', '--overwrite', default=False, is_flag=True,
help='Overwrite existing .md file')
def set_meta(target, keys, overwrite=False):
"""Write image title to corresponding .md file.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring needs to be updated, mention that target can be a directory or a media file.

@saimn
Copy link
Owner

saimn commented May 1, 2016

Much better, thanks :)
Could you also add a test (in test_cli.py) ?

@tohojo
Copy link
Contributor Author

tohojo commented May 1, 2016

Yup, can do; just wanted to check with you that the interface is acceptable ;)

tohojo added 2 commits May 2, 2016 01:18
This can set an arbitrary number of meta keys and also supports creating
meta files for directories (i.e. index.md files).

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
@tohojo
Copy link
Contributor Author

tohojo commented May 1, 2016

And there's the test :)

@saimn saimn merged commit 929f612 into saimn:master May 2, 2016
@saimn
Copy link
Owner

saimn commented May 2, 2016

👍

@saimn saimn added this to the 1.2.0 milestone May 2, 2016
@tohojo tohojo deleted the title-command branch May 2, 2016 09:01
kontza pushed a commit to kontza/sigal that referenced this pull request Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants