Parse positional program args in main

This commit is contained in:
ghubstan 2022-03-26 18:40:33 -03:00
parent 83ffc7ba2d
commit 5e631fff0a
No known key found for this signature in database
GPG Key ID: E35592D6800A861E

View File

@ -1,3 +1,4 @@
import argparse
import configparser
import sys
import threading
@ -209,5 +210,18 @@ class BestPricedOfferBot(BisqClient):
return 'BestPricedOfferBot: ' + 'host=' + self.host + ', port=' + str(self.port) + ', api_password=' + '*****'
def main(host, port, api_password):
BestPricedOfferBot(host, port, api_password).run()
def parse_args(sysargv):
parser = argparse.ArgumentParser()
parser.add_argument('host', help='API daemon hostname or IP address')
parser.add_argument('port', type=int, help='API daemon listening port')
parser.add_argument('api_password', help='API password')
return parser.parse_args(sysargv)
def main():
args = parse_args(sys.argv[1:])
BestPricedOfferBot(args.host, args.port, args.api_password).run()
if __name__ == '__main__':
main()