-
Notifications
You must be signed in to change notification settings - Fork 100
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
config: add support for formatted keys #711
base: main
Are you sure you want to change the base?
Conversation
da1df22
to
549782e
Compare
I just tried your fork because I need this feature, but I somehow can't start the
But I get the I guess there is some code upper-casing the |
@hermlon Can confirm that this doesn't work as expected. I'll look into it! |
26187fe
to
03e8cdc
Compare
@hermlon Turns out my case was just a config error. I added a test for the case you mentioned (I think), i.e. setting a Can you give more details about your setup? Do other things work, e.g. does setting EDIT: Gah, nevermind, that was another issue with my setup. Yes, your format didn't work because we do apparently capitalize things by default here: Lines 411 to 416 in c1a9d91
That doesn't sound like a good idea, so we can make a PR to revert it. Thanks for pointing that out and sorry for the confusion! |
03e8cdc
to
49eb3cb
Compare
2dce1ee
to
126825c
Compare
I tried the commit 126825c; it works well, no abnormalities found yet. 👏 One thing is that something like |
Awesome! Thank for you testing!
Hm, it shouldn't be too hard to implement. I'll look into it! There are a few more places that take values that should be formatted from the command line, so we need some nice solution for them. EDIT: I've looked a bit at this and there's two issues here:
instead, but not sure that's very nice.. |
126825c
to
5f73531
Compare
@OopsYao The latest version should also support |
9bb41cb
to
c7e418c
Compare
289f5c3
to
e3f7629
Compare
I have continued to use this branch for some time and it has served me well. Everything I broke in my earlier escapade was due to my own experiments and config.py. I've opened a new PR to unlock some more power in-line with this feature set, though it does nothing to mitigate the possibility of other adventurous users writing their own volatile configs -- I reckon that comes with the territory. Most of the CI builds are failing for some reason. I'll look into that hopefully within the next month. |
Seems I found a bug. I wrote an alias to help me generate my pretty new refs after adding a library entry from e.g. a bibtex file
For reasons I don't fully understand, this delivers my "lit" library's format string to
|
Thanks for reporting it! I'll take a look probably over the weekend. Also noticed another thing that's missing.
It currently considers |
Indeed. The current form of Line 404 in f390fd7
.formatter in a config key.
also, |
e3f7629
to
bfbc54d
Compare
This should be fixed in the latest version with https://github.com/papis/papis/compare/e3f7629df475631a93b3e009f314e1cff8e1717e..bfbc54d909051f2c835bee1ab57bea3f3c081f9f. The issue was indeed with that |
bfbc54d
to
dafed8f
Compare
This should also work now with the changes from https://github.com/papis/papis/compare/bfbc54d909051f2c835bee1ab57bea3f3c081f9f..dafed8ffa034a813fac0fd5387627d7faf516bdf. |
@pmiam This is a problem for other commands as well and I'm not sure how to fix it in an intuitive manner. For example if you just go
there's no way to know what formatter that text is supposed to have. It works for
Also, if you're using another formatter than then one you set in the config in that many places, it might be worth switching your defaults?
Can you post a traceback for that? I'm not sure in what scenario that would happen. |
Ah, that's actually quite an elegant solution. I hadn't actually realized the set flag could be used like that. We could call attention to it somewhere in the docs. The only alternative I see so far is a campaign to overhaul the CLI. I'm not sure how stable the basic interface is. I have seen other PRs working to merge/extend other commands, but I doubt deprecating basic flags like
Indeed, I might switch my defaults at this point, I've become enamored with my jinja-given powers. It's important to handle this middle ground, though, as it's an explicit feature of this PR. |
To be more precise, the if-condition I referenced is always false in the case when I set my e.g. with config:
I run
|
Oops, this just looks like I forgot to update the |
I don't think the interface is very stable.. or at least we don't do any particular testing to ensure it stays too compatible :( That being said, stuff like papis --set add-folder-name "MY_SPECIAL_FORMAT" add <SOMETHING>` I'm not sure if we necessarily want to deprecate them.. |
41cfafe
to
1e0e6e2
Compare
I'm happy to report no more issues over the last week. Your rename fix has performed perfectly and it's helped me re-organize my largest library's file tree without pains. |
1e0e6e2
to
5ae0671
Compare
I have another little patch to offer:
|
5ae0671
to
16bad9c
Compare
Nice catch! Added it in the latest rebase. |
16bad9c
to
6c7edbf
Compare
This adds support for entries like these in the configuration file (see discussion in #662):
where the first setting uses the default formatter (whatever
formatter
is set to) and the second setting overwrites the default and forces thejinja2
formatter. In general,key[.formatter]
is how this looks like.For this, it adds some functionality:
papis.config.getformattedstring
: this looks thorough the config file for any version ofkey.[formatter]
and returns the last one it finds.papis.strings.FormattedString
: a class that's just a(formatter, string)
tuple and gets passed topapis.format.format
to allow picking the formatter for each individual string. This is mostly inspired byprompt_toolkit.FormattedText
.papis.cli.FormattedStringParamType
: aclick.ParamType
that automatically converts command-line parameters toFormattedString
. It also shows a nice text--file-name FORMATTED-TEXT
in the command line to mark entries that can be format strings.TODO:
papis.commands.add::run
works correctly with formatted strings. Need to add some tests for that.Fixes #662.