Skip to content

Commit

Permalink
adding template for prosper CLI Applications
Browse files Browse the repository at this point in the history
  • Loading branch information
lockefox committed Nov 18, 2017
1 parent e13c128 commit b26c617
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions prosper/common/prosper_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Plumbum CLI wrapper for easier/common application writing"""
import platform

from plumbum import cli

import prosper.common.prosper_logging as p_logging

class ProsperApplication(cli.Application):
"""parent-wrapper for CLI applications"""

debug = cli.Flag(
['d', '--debug'],
help='DEBUG MODE: do not write to prod'
)

verbose = cli.Flag(
['v', '--verbose'],
help='enable verbose messaging'
)

config_path = None # TODO: force child to implement var?
@cli.switch(
['--config'],
str,
help='Override default config')
def override_config(self, config_path):
"""override config object with local version"""
self.config_path = config_path

@cli.switch(
['--dump-config'],
help='Dump default config to stdout')
def dump_config(self):
"""dumps configfile to stdout so users can edit/implement their own"""
with open(self.config_path, 'r') as cfg_fh:
base_config = cfg_fh.read()

print(base_config)
exit()

@property
def logger():
"""builds a logger on-demand when first called"""
pass

@property
def config():
"""builds a ProsperConfig object on-demand when first called"""
pass

if __name__ == '__main__':
ProsperApplication.run() # test hook

0 comments on commit b26c617

Please sign in to comment.