Skip to content

Add the ability to add additional identities via the command line#413

Open
rustafariandev wants to merge 1 commit intoromanz:masterfrom
rustafariandev:feature/additional_identities
Open

Add the ability to add additional identities via the command line#413
rustafariandev wants to merge 1 commit intoromanz:masterfrom
rustafariandev:feature/additional_identities

Conversation

@rustafariandev
Copy link

No description provided.

@rustafariandev rustafariandev force-pushed the feature/additional_identities branch from 502e578 to eab0362 Compare January 30, 2023 20:06
@@ -114,6 +114,10 @@ def create_agent_parser(device_type):

p.add_argument('identity', type=_to_unicode, default=None,
Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be simpler to add nargs='+' to the existing identity argument:

p.add_argument('identity', type=_to_unicode, default=None, nargs='+',
               help='proto://[user@]host[:port][/path]')

See https://docs.python.org/3/library/argparse.html#nargs

Copy link
Author

Choose a reason for hiding this comment

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

Let me test how that works.

@rustafariandev
Copy link
Author

That conflicts with the other nargs argument at

p.add_argument('command', type=str, nargs='*', metavar='ARGUMENT',

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-c', action='store_true')
parser.add_argument('foo', nargs='+')
parser.add_argument('bar', nargs='*', metavar='ARGUMENT')
print(parser.parse_args('-c c a b --  1 2 3'.split()))

The output

Namespace(c=True, foo=['c', 'a', 'b', '1', '2', '3'], bar=[])

@romanz
Copy link
Owner

romanz commented Feb 5, 2023

You're right - it won't work :(

@romanz
Copy link
Owner

romanz commented Feb 5, 2023

Can you export you relevant identities/pubkeys into a text file?
(see #115 for the discussion & #116 for the implementation)

@rustafariandev
Copy link
Author

Yes, I can. This was more for convenience than anything else.
It was to avoid me doing something like this.

onlykey-agent  <(echo "<git@github.com|ed25519>";echo "<user@example.com|ed25519>") --shell

Or creating the file ahead of time.

The file approach also works.

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.

2 participants