Closed AbcSxyZ closed 2 years ago
Do you think the regex from grep is safe : ^ -'?
The only thing I don't like is the inclusion of -?
because that won't easily work as an environment variable.
I tried grep '^ -[-a-z0-9]\+\(=.*\)\?$'
, on both 1.14 and 1.21:
$ ./dogecoind-1.14 -help -help-debug |grep '^ -[-a-z0-9]\+\(=.*\)\?$' |sort
-acceptnonstdtxn
-addnode=<ip>
-alertnotify=<cmd>
-alerts
-assumevalid=<hex>
-banscore=<n>
-bantime=<n>
-bind=<addr>
-bip9params=deployment:start:end
-blockmaxsize=<n>
-blockmaxweight=<n>
-blockmintxfee=<amt>
-blocknotify=<cmd>
-blockprioritysize=<n>
-blockreconstructionextratxn=<n>
-blocksonly
-blockversion=<n>
-bytespersigop
-checkblockindex
-checkblocks=<n>
-checklevel=<n>
-checkmempool=<n>
-checkpoints
-conf=<file>
-connect=<ip>
-daemon
-datacarrier
-datacarriersize
-datadir=<dir>
-dbcache=<n>
-dblogsize=<n>
-debug=<category>
-disablesafemode
-disablewallet
-discardthreshold=<amt>
-discover
-dns
-dnsseed
-dropmessagestest=<n>
-dustlimit=<amt>
-externalip=<ip>
-fallbackfee=<amt>
-feefilter
-flushwallet
-forcednsseed
-fuzzmessagestest=<n>
-harddustlimit=<amt>
-help-debug
-incrementalrelayfee=<amt>
-keypool=<n>
-limitancestorcount=<n>
-limitancestorsize=<n>
-limitdescendantcount=<n>
-limitdescendantsize=<n>
-limitfreerelay=<n>
-listen
-listenonion
-loadblock=<file>
-logips
-logtimemicros
-logtimestamps
-maxconnections=<n>
-maxmempool=<n>
-maxorphantx=<n>
-maxreceivebuffer=<n>
-maxsendbuffer=<n>
-maxsigcachesize=<n>
-maxtimeadjustment
-maxtipage=<n>
-maxtxfee=<amt>
-maxuploadtarget=<n>
-mempoolexpiry=<n>
-mempoolreplacement
-minrelaytxfee=<amt>
-mintxfee=<amt>
-mocktime=<n>
-nodebug
-onion=<ip:port>
-onlynet=<net>
-par=<n>
-paytxfee=<amt>
-peerbloomfilters
-permitbaremultisig
-pid=<file>
-port=<port>
-printpriority
-printtoconsole
-privdb
-proxy=<ip:port>
-proxyrandomize
-prune=<n>
-regtest
-reindex
-reindex-chainstate
-relaypriority
-rescan
-rest
-rpcallowip=<ip>
-rpcauth=<userpw>
-rpcbind=<addr>
-rpccookiefile=<loc>
-rpcnamecoinapi
-rpcpassword=<pw>
-rpcport=<port>
-rpcserialversion
-rpcservertimeout=<n>
-rpcthreads=<n>
-rpcuser=<user>
-rpcworkqueue=<n>
-salvagewallet
-seednode=<ip>
-sendfreetransactions
-server
-shrinkdebugfile
-spendzeroconfchange
-stopafterblockimport
-sysperms
-testnet
-testsafemode
-timeout=<n>
-torcontrol=<ip>:<port>
-torpassword=<pass>
-txconfirmtarget=<n>
-txindex
-uacomment=<cmt>
-upgradewallet
-usehd
-version
-wallet=<file>
-walletbroadcast
-walletnotify=<cmd>
-walletrbf
-walletrejectlongchains
-whitebind=<addr>
-whitelist=<IP address or network>
-whitelistforcerelay
-whitelistrelay
-zapwallettxes=<mode>
-zmqpubhashblock=<address>
-zmqpubhashtx=<address>
-zmqpubrawblock=<address>
-zmqpubrawtx=<address>
$ ./dogecoind-1.21 -help -help-debug |grep '^ -[-a-z0-9]\+\(=.*\)\?$' |sort
-acceptnonstdtxn
-addnode=<ip>
-addresstype
-addrmantest
-alertnotify=<cmd>
-asmap=<file>
-assumevalid=<hex>
-avoidpartialspends
-bantime=<n>
-bind=<addr>[:<port>][=onion]
-blockfilterindex=<type>
-blockmaxweight=<n>
-blockmintxfee=<amt>
-blocknotify=<cmd>
-blockreconstructionextratxn=<n>
-blocksdir=<dir>
-blocksonly
-blockversion=<n>
-bytespersigop
-chain=<chain>
-changetype
-checkblockindex
-checkblocks=<n>
-checklevel=<n>
-checkmempool=<n>
-checkpoints
-conf=<file>
-connect=<ip>
-daemon
-datacarrier
-datacarriersize
-datadir=<dir>
-dbbatchsize
-dbcache=<n>
-dblogsize=<n>
-debug=<category>
-debugexclude=<category>
-debuglogfile=<file>
-deprecatedrpc=<method>
-disablewallet
-discardfee=<amt>
-discover
-dns
-dnsseed
-dropmessagestest=<n>
-dustrelayfee=<amt>
-externalip=<ip>
-fallbackfee=<amt>
-feefilter
-flushwallet
-forcednsseed
-help-debug
-includeconf=<file>
-incrementalrelayfee=<amt>
-keypool=<n>
-limitancestorcount=<n>
-limitancestorsize=<n>
-limitdescendantcount=<n>
-limitdescendantsize=<n>
-listen
-listenonion
-loadblock=<file>
-logips
-logthreadnames
-logtimemicros
-logtimestamps
-maxapsfee=<n>
-maxconnections=<n>
-maxmempool=<n>
-maxorphantx=<n>
-maxreceivebuffer=<n>
-maxsendbuffer=<n>
-maxsigcachesize=<n>
-maxtimeadjustment
-maxtipage=<n>
-maxtxfee=<amt>
-maxuploadtarget=<n>
-mempoolexpiry=<n>
-minimumchainwork=<hex>
-minrelaytxfee=<amt>
-mintxfee=<amt>
-mocktime=<n>
-networkactive
-onion=<ip:port>
-onlynet=<net>
-par=<n>
-paytxfee=<amt>
-peerblockfilters
-peerbloomfilters
-peertimeout=<n>
-permitbaremultisig
-persistmempool
-pid=<file>
-port=<port>
-printpriority
-printtoconsole
-privdb
-proxy=<ip:port>
-proxyrandomize
-prune=<n>
-regtest
-reindex
-reindex-chainstate
-rescan
-rest
-rpcallowip=<ip>
-rpcauth=<userpw>
-rpcbind=<addr>[:port]
-rpccookiefile=<loc>
-rpcpassword=<pw>
-rpcport=<port>
-rpcserialversion
-rpcservertimeout=<n>
-rpcthreads=<n>
-rpcuser=<user>
-rpcwhitelist=<whitelist>
-rpcwhitelistdefault
-rpcworkqueue=<n>
-seednode=<ip>
-segwitheight=<n>
-server
-settings=<file>
-shrinkdebugfile
-signet
-signetchallenge
-signetseednode
-spendzeroconfchange
-startupnotify=<cmd>
-stopafterblockimport
-stopatheight
-sysperms
-testnet
-timeout=<n>
-torcontrol=<ip>:<port>
-torpassword=<pass>
-txconfirmtarget=<n>
-txindex
-uacomment=<cmt>
-vbparams=deployment:start:end[:min_activation_height]
-version
-wallet=<path>
-walletbroadcast
-walletdir=<dir>
-walletnotify=<cmd>
-walletrbf
-walletrejectlongchains
-whitebind=<[permissions@]addr>
-whitelist=<[permissions@]IP address or network>
-whitelistforcerelay
-whitelistrelay
-zmqpubhashblock=<address>
-zmqpubhashblockhwm=<n>
-zmqpubhashtx=<address>
-zmqpubhashtxhwm=<n>
-zmqpubrawblock=<address>
-zmqpubrawblockhwm=<n>
-zmqpubrawtx=<address>
-zmqpubrawtxhwm=<n>
-zmqpubsequence=<address>
-zmqpubsequencehwm=<n>
These give 1 less entry than your regex, removing -?
Is it possible to set ?
as environment variables ? I'm not sure if it's possible at all, shell syntax may not allow it. It would be an unusable option as environment variable.
Maybe we could keep the -?
in the list to avoid a complex regex, it shouldn't have any impact.
Or simply : ^ -[a-z]+
, just getting a word.
First error caught with CI tests :) I used a single space in the regex !
I replaced the grep command by grep -E '^ -[a-z]+'
, let me know what do you think about that.
And for the hook, you're ok for the list or you would prefer raw help menus ?
Function extracted, ready for review
Since the additional commits only change code introduced with the first commit, would you mind giving those a squash?
Done
10/10 with pylint
Fix #28. Needed also for test coverage of Dockerfile in #25.
Use of
-help
menu to get option instead of man pages.Do you think the regex from grep is safe :
^ -'
? It handles all options with 2 space from the start of the line, do you know if it's done like that ? I started with^ *-
, but some options may use others in their description like-listen
or-checkblockindex
.What would you like to hook from here ? Do we stay with grep, or we could break the grep and use regex from python to generate a more raw entry easier to hook ? The grep option may be nicer but harder to test.
With the grep, we may hook with something like this:
Or if we want to test also the regex on a raw file, we break it and return some raw string like the help menu.
Because it uses executables, a test from #25 is breaking for
dogecoin-qt
with the following:Issue related to X window system, would be great to have a discussion related to
dogecoin-qt
as you mentioned previously, to see how/if we handle it.