-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat(rename): allow batch and auto-renaming from pattern #810
Conversation
e0ff4b4
to
5352a08
Compare
While the new features work fine during testing with my live library, they don't behave properly during automatic testing. I am trying to test via the CLI to improve coverage and parse the logs but the behaviour of |
9c75822
to
54d68fc
Compare
This avoids conflicts when running under Pytest
54d68fc
to
25aa232
Compare
I went ahead and added some more tests too. It's at 98% coverage now. EDIT: I need to monkeypatch something else too. I'll start the windows machine to review the changes there. |
c915cb9
to
4db6e34
Compare
4db6e34
to
37264eb
Compare
37264eb
to
641f74e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this! ❤️ This is definitely a nice thing to have, since rename was very limited before, but the interface needs a bit of work.
I've left a few comments with suggestions and questions.
Thank you very much for your feedback! Let me address the changes! If you feel brave, you can check if it fails on your end too in pytest if you don't have |
b27cd5c
to
1012bf4
Compare
Co-authored-by: Alex Fikl <alexfikl@gmail.com>
1012bf4
to
04c17f1
Compare
First of all, great contribution! ❤️ I just started reviewing this but then I realised that things are changing under my nose and maybe it's not quite yet the moment for detailed feedback on the documentation. I'm happy to take a look at the docs again once things stabilise 😅. So I just have the following comments:
|
2820a1c
to
78839e2
Compare
@jghauser you can test it now if you want! EDIT: I don't know if that will affect you, but I am going to test pushing a couple tweaks for the |
978bc4e
to
d75d421
Compare
@kiike I looked through the code a bit and moved some things around. It all looks good to me now! 🎉
Yeah, it fails on my system too 😢 I looked a bit, but not sure why it's doing that.. best guess is that the documents in the database are stored in a mutable list and mutable references are returned on the
That's a good change either way! We should be using the more platform independent version from
I'm not sure I understand why you're not a fan of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code all looks good to me now!
@jghauser If you get the chance to look over the docs 😁
I was just looking through the docs and writing up some suggestions regarding the I can see two solutions:
What do you think? |
Oops, I forgot about the For comparison, in |
Yes that seems sensible. It would keep the amounts of flags small and is in line with how |
I've finished up with the docs (assuming the functionality just discussed). I'm just gonna post the whole thing here as that's easier (especially cause the code might still change a bit) and I'll be away for a few days over the weekend. I've added a small paragraph after the intro sentence, because I think that's useful information specific to this command (and applicable to almost all examples below). The ``rename`` command is used to rename document folders based on user input,
a provided formatting pattern, or :confval:`add-folder-name`.
It will (except when run with ``--all``) bring up the picker with a list of
documents that match the query. In the picker, you can select one or more
documents and then initiate renaming by pressing enter. Folder names are cleaned,
so that various characters (white spaces, punctuation, capital letters, and some
others) are automatically converted.
Examples
^^^^^^^^
- Rename folders for documents whose author is "Rick Astley". You can then either
enter a new folder name or accept Papis' suggestion. The suggested folder name
will be generated according to :confval:`add-folder-name` or, if this option
isn't set, the current folder name.
.. code:: sh
papis rename author:"Rick Astley"
- You can use ``--folder-name`` to pass in your desired name. This option
supports Papis formatting patterns. You will be asked for confirmation
before the folder is renamed.
.. code:: sh
papis rename --folder-name "{doc[author]}-never-gonna" author:"Rick Astley"
This will give you a folder named "rick-astley-never-gonna".
- To stop Papis from asking for confirmation, use the ``--batch`` flag:
.. code:: sh
papis rename --batch author:"Rick Astley"
- If you want to rename all documents without narrowing down your selection in
the picker, you can use the ``--all`` flag. Be careful when combining this
with ``--batch``, as you might end up renaming a lot folders without
confirmation:
.. code:: sh
papis rename --all author:"Rick Astley"
|
Nice! absolutely sure because I am not looking closely at the
Yeah, I couldn't pinpoint the source of the problem since that only happened during pytest. We could deepcopy
Good! I'll keep an eye for more raw commands!
If it was |
∙ ∙ Co-authored-by: Julian Hauser <julian@julianhauser.com>
As far as I can know, the the git code mostly assumes that it's all well set up and all the files exist and are tracked, so it's pretty brittle. On the bright side, it's all pretty well separated in
Doing a deep copy seems very expensive, so I'm not a big fan. For now this is fine. Maybe open an issue about it so we keep track?
Ah, fair enough! Completely agree on all of those points! We should probably go over those at some point and choose slightly better names, but it's tedious, so not sure it's gonna be on the top of the list :( For now, I'm thinking consistency between commands is at least good to have. |
This is good to go from my end, so we can get it in! |
362ebac
to
1108ded
Compare
Got it! I am not using git for my library but probably should. I'll give it a go sometime!
Sure, I'll create an issue for that! Spelunking into the code to see why it's being mutated will be interesting!
I agree. Naming is hard 😄
Definitely!
I think so! It has received a good makeover. I am happy with the functionality now and the features added by you too regarding git! |
Thanks for working on this! In it goes 🚀 |
When I develop a feature, I try to dogfood, so sometimes I end up using default values of config options such as
add-folder-name
, thus creating folders that don't end up like I like.papis rename
can rename entries but is now pretty limited.With this WIP pull request, I am trying to make
papis rename
a bit more powerful:It's taking form:
With slug enabled:
Without:
Picking files:
What do you think?