Py-KMS-Organization / py-kms

KMS Server Emulator written in Python
https://py-kms.readthedocs.io/en/latest/readme.html
The Unlicense
629 stars 114 forks source link

pykms_Client fails to parse command line options correctly #113

Open sborrill opened 5 months ago

sborrill commented 5 months ago

When specifying a positional argument, using the -m flag appears to read the wrong parameter:

% python3.11 pykms_Client.py -m Windows10 192.168.10.1 optional py-kms client argument -m: expected one argument, unrecognized: '192.168.10.1'. Exiting...

simonmicro commented 5 months ago

Wrong way around:

python3 pykms_Client.py 192.168.10.1 -m Windows10

First the positional arguments, then the optional ones.

sborrill commented 5 months ago

This contradicts the documentation (and also every other *nix utility). Note that --help shows the options should come before the positional arguments as is conventional:

% python3.11 pykms_Client.py --help

py-kms: KMS Client Emulator written in Python
---------------------------------------------

usage: pykms_Client.py [-m {WindowsVista,Windows7,Windows8,Windows8.1,Windows10,Office2010,Office2013,Office2016,Office2019}] [-c CMID] [-n MACHINE] [-t0 TIMEOUTIDLE] [-t1 TIMEOUTSNDRCV] [-y]
                       [-V {CRITICAL,ERROR,WARNING,INFO,DEBUG,MININFO}] [-F LOGFILE [LOGFILE ...]] [-S LOGSIZE] [-D DISCOVERY] [-h]
                       [ip] [port]
simonmicro commented 5 months ago

Hmm, this is indeed strange! The help being wrong is really strange, as that part should come 1:1 from argparse, although the original author did quite some magic with combining multiple sub-parsers. Idk, I think I'll reopen this to either fix the documentation or the command argument order (I think the first will be better for compatibility).

If anybody wants to take a shot at this, please go ahead!