old_contents: #!/usr/bin/python3
  
  #
  # Command line usage:
  # $ python3 fortune-client.py		# Get pithy saying
  # $ python3 fortune-client.py info	# Get server metadata
  #
  
  import json
  import os
  import sys
  
  # import from the 21 Developer Library
  from two1.commands.config import Config
  from two1.lib.wallet import Wallet
  from two1.lib.bitrequests import BitTransferRequests
  
  # set up bitrequest client for BitTransfer requests
  wallet = Wallet()
  username = Config().username
  requests = BitTransferRequests(wallet, username)
  
  # server address
  server_url = 'http://localhost:12012/'
  
  def cmd_fortune():
      sel_url = server_url + 'fortune'
      answer = requests.get(url=sel_url.format())
      print(answer.text)
  
  def cmd_info():
      sel_url = server_url
      answer = requests.get(url=sel_url.format())
      print(answer.text)
  
  if __name__ == '__main__':
      if len(sys.argv) == 2 and sys.argv[1] == "info":
          cmd_info()
      else:
          cmd_fortune()
  
  
new_contents: #!/usr/bin/python3
  
  #
  # Command line usage:
  # $ python3 fortune-client.py		# Get pithy saying
  # $ python3 fortune-client.py info	# Get server metadata
  #
  
  import json
  import os
  import sys
  import click
  
  # import from the 21 Developer Library
  from two1.commands.config import Config
  from two1.lib.wallet import Wallet
  from two1.lib.bitrequests import BitTransferRequests
  
  # set up bitrequest client for BitTransfer requests
  wallet = Wallet()
  username = Config().username
  requests = BitTransferRequests(wallet, username)
  
  FORTUNECLI_VERSION = '1.0'
  DEFAULT_ENDPOINT = 'http://localhost:12012/'
  
  @click.group(invoke_without_command=True)
  @click.option('--endpoint', '-e',
                default=DEFAULT_ENDPOINT,
                metavar='STRING',
                show_default=True,
                help='API endpoint URI')
  @click.option('--debug', '-d',
                is_flag=True,
                help='Turns on debugging messages.')
  @click.version_option(FORTUNECLI_VERSION)
  @click.pass_context
  def main(ctx, endpoint, debug):
      """ Command-line Interface for the fortune cookie service
      """
  
      if ctx.obj is None:
          ctx.obj = {}
  
      ctx.obj['endpoint'] = endpoint
  
      if ctx.invoked_subcommand is None:
          cmd_fortune(ctx)
  
  
  def cmd_fortune(ctx):
      sel_url = ctx.obj['endpoint'] + 'fortune'
      answer = requests.get(url=sel_url.format())
      print(answer.text)
  
  
  @click.command(name='info')
  @click.pass_context
  def cmd_info(ctx):
      sel_url = ctx.obj['endpoint']
      answer = requests.get(url=sel_url.format())
      print(answer.text)
  
  main.add_command(cmd_info)
  
  if __name__ == "__main__":
      main()
  
  
subject: convert to click CLI API