[PATCHES] improve extensions support

HacKan hackan at gmail.com
Mon Feb 6 23:49:34 CET 2017


Ok, after a while going round and round I realized of an easier way, to
keep it simple stupid:

check_extension_and_load show "$@" || cmd_show "$@"

Here goes the patch attached.

Thanks!


On 02/06/2017 06:33 PM, Lars Flitter wrote:
> Hi,
>
> I like the idea of overriding the built in pass commands and
> functions. I was looking for a way to override the clip function used
> in the show command. With this approach overridden functions are
> contained within a single extension, not interfering with other
> extensions that might rely on the original function.
>
> The way cmd_internal calls the cmd_-functions allows for a nice way to
> alias the multi-name functions.
>
> The only thing I'm missing is built-in support to override the
> implicit show command with an extension.
>
> This could be achieved by adding
> check_extension_and_load show "$@" && exit 0
>
> before the final
> cmd_show "$@"
>
> Regards,
> Lars
>
> On 06.02.2017 17:40, HacKan wrote:
>> Hello there! I spent the last few days playing around with pass, so I
>> forked it [1] and changed the way it handles extensions, because I
>> wanted to allow extensions to override internal commands. I.E. if
>> someone wants to modify the way /generate/ works, there's no need to
>> touch pass's core but simply create an extension named /generate.bash
>> /and that's all/./
>>
>> Here's the rough changes list:
>>
>>   * Modified the way commands are interpreted in the script: replaced
>>     the switch case selection to a more flexible eval'd one.
>>   * Changed how extensions are handled: now extensions are loaded first,
>>     before interpreting the command as an internal command. This allows
>>     extensions to override internal commands. A helper function is
>>     provided so that an overridden function can still be called from the
>>     extension.
>>   * Issuing help command now shows help from the extensions if they
>>     implement a function named help_{extension name}(). Otherwise, it
>>     will list enabled extensions as commands.
>>
>> This keeps backwards compatibility at 100%, existing extensions are too
>> 100% compatible. So for the final user these patches doesn't have any
>> effect at all.
>>
>> Patches and signed hashes are attached.
>>
>> Also, I tested these and all tests passed (attached as
>> /tests-result.txt/). Note that tests must be fixed first (see /[PATCH]
>> Fixes for tests/ [2]).
>>
>> A sample /pass --help/ output with a couple of extensions I made is
>> attached (/help-example.txt/).
>>
>> Attachment list:
>> 0001-Changed-function-switch-based-on-parameters-by-a-mor.patch
>> 0002-Added-helper-override_function-to-enable-extensions-.patch
>> 0003-Modified-cmd_usage-to-show-extensions-usage-help-too.patch
>> 0004-Minor-bugfixes-in-cmd_usage-when-showing-extensions-.patch
>> 0005-Fixed-multiname-functions-parameters-were-not-being-.patch
>> 0006-Small-bugfix-in-usage-command.-Also-changed-spaces-f.patch
>> SHA512SUMS
>> SHA512SUMS.sig
>> help-example.txt
>> tests-result.txt
>>
>> Cheers!
>>
>> [1]: https://github.com/HacKanCuBa/passh
>> [2]:
>> https://lists.zx2c4.com/pipermail/password-store/2017-February/002727.html
>>
>>
>> -- 
>> HacKan || Iván
>> GPG: 0x35710D312FDE468B
>>
>>
>>
>> _______________________________________________
>> Password-Store mailing list
>> Password-Store at lists.zx2c4.com
>> https://lists.zx2c4.com/mailman/listinfo/password-store
>>
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/password-store

-- 
HacKan || Iván
GPG: 0x35710D312FDE468B

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-Fix-allow-implicit-show-command-to-be-an-extension.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/36096f83/attachment.bin>
-------------- next part --------------
c61e47b84e2e7318c3366f586e87304722646a197f21d895c42801435cd670cca007c666e8edcc102048acc5150cb6f42857fa78dc113d9ecb271571fd4ac36d  0001-Changed-function-switch-based-on-parameters-by-a-mor.patch
d6781bf10dcf154c48a548bb782ffb72db65fdacc9e0da1d4f6381ffb064239929419b9b54a6a01007d0f9c8cbe61c99d26be0f7d7c37efabafed69d98079fe4  0002-Added-helper-override_function-to-enable-extensions-.patch
85d6b9ae376e42be0a8101055f2ea196fe453fd5985015884c424d6be6af4689a0eee6f813c5362dff4f79e751c17e623371d897665f69c305d6219c8fa63d38  0003-Modified-cmd_usage-to-show-extensions-usage-help-too.patch
4dd01d2762e6988cf83841ce12939a1bcfce99939f01c75111c2e66e535454fbd1ed09e68bc92660114b18ffd19e173981f40dd23916d00ed443199d1e5de8da  0004-Minor-bugfixes-in-cmd_usage-when-showing-extensions-.patch
730af4c505ec80fa2bacf32f5b6e8374718b928fda568a0aa628c9aed451c8eb58f6e6a2ab874383840d2084e485456bade09b32c6a2ef9d02ec106d42c8f76c  0005-Fixed-multiname-functions-parameters-were-not-being-.patch
6e287545124086fdfae2402d85a278fc38a41bdeefd3fdb5c00aa65c0fa99b34f2222d02f139298dff042cf6482a5ff79fcae249a60aee3bc71645b438e9a453  0006-Small-bugfix-in-usage-command.-Also-changed-spaces-f.patch
2fec603a1876d30c515cfd94ded1126b41ea65855723668c5404d4c03750d5db6578cce6e8fbbfa50e0543748d2ba1253143efeef94f68e27efb0c568ca00746  0007-Fix-allow-implicit-show-command-to-be-an-extension.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SHA512SUMS.sig
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/36096f83/attachment.sig>


More information about the Password-Store mailing list