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

added help section, refactor with argparse #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ranfdev
Copy link

@ranfdev ranfdev commented Nov 23, 2020

As said in issue #40, I've rewritten the client to use argparse, so that the users can have a better user experience.

I haven't tested every function, so there may be many bugs.
Examples now:

❯ python -m onlykey -h
usage: __main__.py [-h]
                   {version,fwversion,help,getlabels,getkeylabels,setslot,wipeslot,wipekey,idletimeout,keylayout,wipemode,keytypespeed,ledbrightness,storedkeymode,derivedkeymode,backupkeymode,2ndprofilemode,sysadminmode,lockbutton,hmackeymode,rng,ping,wink,setkey,init,credential}
                   ...

optional arguments:
  -h, --help            show this help message and exit

commands:
  {version,fwversion,help,getlabels,getkeylabels,setslot,wipeslot,wipekey,idletimeout,keylayout,wipemode,keytypespeed,ledbrightness,storedkeymode,derivedkeymode,backupkeymode,2ndprofilemode,sysadminmode,lockbutton,hmackeymode,rng,ping,wink,setkey,init,credential}
    version             display the version of the app
    fwversion           display the version of the OnlyKey firmware
    help                this message
    getlabels           return slot's labels
    getkeylabels        show key's labels
    setslot             set slot action, label ...
    wipeslot            wipe slot
    wipekey             wipe key
    idletimeout         OnlyKey locks after idletimeout is reached
    keylayout           set keyboard layout
    idletimeout         set idletimeout
    wipemode            set wipemode
    keytypespeed        set keytypespeed
    ledbrightness       set ledbrightness
    storedkeymode       set storedkeymode
    derivedkeymode      set derivedkeymode
    backupkeymode       set backupkeymode
    2ndprofilemode      set 2ndprofilemode
    sysadminmode        set sysadminmode
    lockbutton          set lockbutton
    hmackeymode         set hmackeymode
    rng                 generate rng content
    ping                send ping
    wink                send wink command to key (blinks LED a few times).
    setkey              set key in a slot
    init                setup onlykey
    credential          credential actions
❯ python -m onlykey setslot -h
usage: __main__.py setslot [-h] id {label,ecckeylabel,rsakeylabel,url,addchar1,delay1,username,addchar2,delay2,password,addchar3,delay3,2fa,totpkey,addchar4,addchar5} value

positional arguments:
  id
  {label,ecckeylabel,rsakeylabel,url,addchar1,delay1,username,addchar2,delay2,password,addchar3,delay3,2fa,totpkey,addchar4,addchar5}
  value

optional arguments:
  -h, --help            show this help message and exit
❯ python -m onlykey keylayout --list-all
1 USA_ENGLISH (Default)
2 CANADIAN_FRENCH
3 CANADIAN_MULTILINGUAL
4 DANISH
5 FINNISH
6 FRENCH
7 FRENCH_BELGIAN
8 FRENCH_SWISS
9 GERMAN
10 GERMAN_MAC
11 GERMAN_SWISS
12 ICELANDIC
13 IRISH
14 ITALIAN
15 NORWEGIAN
16 PORTUGUESE
17 PORTUGUESE_BRAZILIAN
18 SPANISH
19 SPANISH_LATIN_AMERICA
20 SWEDISH
21 TURKISH
22 UNITED_KINGDOM
23 US_INTERNATIONAL
24 CZECH
25 SERBIAN_LATIN_ONLY
26 HUNGARIAN
27 DANISH MAC
28 US_DVORAK

I have added a __main__.py file to help me test things more quickly from the shell.
Most of the commands should work as before. Even the interactive shell is still there.
I'm going to leave this here, in the hope somebody reviews the code and test it.

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.

1 participant