#!/usr/bin/env python

#
# ddr-hello(world)
#

DESCRIPTION_SHORT = """Template for making your own CLI tools."""

DESCRIPTION_LONG = """

- Decide what your command should do.
- Decide on your command name and arguments.
- Copy this file e.g. "cp ddr-hello ddr-MYCMD".
- Replace all instances of "ddr-hello" in this file with "ddr-MYCMD".
- Program your arguments (e.g. "parser.add_argument"). See the Python docs
  for help: https://docs.python.org/2.7/library/argparse.html
- Replace hello() with your own functions.
- Add supporting functions as necessary.
  Caveat: most of the actual work should be done by DDR.* modules.
  Most code in this file should 
  - parse arguments
  - read files, gather, and normalize input data
  - print or log feedback to the user.
- Add command to ddr-cmdln/ddr/setup.py.
- Run "cd /usr/local/src/ddr-local; sudo make setup-ddr-cmdln" to compile.
- Document your functions; specify inputs and outputs and their types.
- Update DESCRIPTION and EPILOG. Include example usage.

USAGE

$ ddr-hello world
$ ddr-hello world --arg1=whatever --arg2

---"""

import argparse
import logging
import sys

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(levelname)-8s %(message)s',
    stream=sys.stdout,
)

# ----------------------------------------------------------------------
# Your code goes here


def hello(arg1, arg2=None, arg3=None):
    print('hello %s' % arg1)


# ----------------------------------------------------------------------
# specify arguments and launch your function(s)

def main():

    parser = argparse.ArgumentParser(
        description=DESCRIPTION_SHORT,
        epilog=DESCRIPTION_LONG,
        formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument('arg1', help='Positional argument')
    parser.add_argument('-a', '--arg2', help='Optional argument')
    parser.add_argument('-b', '--arg3', action='store_true', help='Binary flag.')
    args = parser.parse_args()

    hello(args.arg1, args.arg2, args.arg3)


if __name__ == '__main__':
    main()
