import logging

import vulcan

import click


log = logging.getLogger(__name__)


class Context(object):
    '''Dummy Context class for Click group context.
    '''
    pass


@click.group()
@click.option('--debug', is_flag=True, help='Enables debug mode.')
@click.option('--config', type=click.Path(exists=True), default='./vulcan.yaml')
@click.version_option(vulcan.__version__)
@click.pass_context
def cli(ctx, debug, config):
    '''This function is the click group for all other CLI commands to belong to.

    It mostly just sets up context and logging.
    '''
    lvl = logging.DEBUG if debug else logging.INFO
    logging.basicConfig(level=lvl, format='%(asctime)s %(levelname)s %(message)s')
    ctx.obj = Context()
    ctx.obj.cfg = vulcan.config.Config(config)
    ctx.obj.debug = debug


@cli.command()
@click.pass_context
def install(ctx):
    formulas = ctx.obj.cfg.formulas
    for formula in formulas:
        formula.install()

@cli.command()
@click.pass_context
def update(ctx):
    formulas = ctx.obj.cfg.formulas
    for formula in formulas:
        formula.update()


if __name__ == '__main__':
    cli() #pylint: disable=no-value-for-parameter

@@ -330,16 +330,76 @@
 an.yaml'
+, help='Configuration file path. Defaults to ./vulcan.yaml.'
 )%0A@click
@@ -494,129 +494,112 @@
  '''
-This function is the click group for all other CLI commands to belong to.%0A%0A    It mostly just sets up context and logging
+Formula build tool for SaltStack.%0A%0A    See https://github.com/iamseth/saltstack-vulcan for documentation
 .%0A  
@@ -762,16 +762,46 @@
 ntext()%0A
+    ctx.obj.cfg_file = config%0A
     ctx.
@@ -916,24 +916,75 @@
 stall(ctx):%0A
+    '''Install all non-installed formulas.%0A    '''%0A
     formulas
@@ -1111,24 +1111,67 @@
 pdate(ctx):%0A
+    '''Update or install formulas.%0A    '''%0A
     formulas

update CLI documentation