# Path: pyqi/commands/make_bash_completion.py
# class BashCompletion(Command):
#     BriefDescription = "Construct a bash completion script"
#     LongDescription = ("Construct a bash tab completion script that will search"
#         " through available commands and options")
#     
#     CommandIns = ParameterCollection([
#         CommandIn(Name='command_config_module', DataType=str,
#                   Description="CLI command configuration module",
#                   Required=True),
#         CommandIn(Name='driver_name', DataType=str,
#                   Description="name of the driver script", Required=True)
#     ])
# 
#     CommandOuts = ParameterCollection([
#         CommandOut(Name='result', DataType=str,
#                    Description="result bash completion script")
#     ])
# 
#     def run(self, **kwargs):
#         driver = kwargs['driver_name']
#         cfg_mod_path = kwargs['command_config_module']
#         cfg_mod = _get_cfg_module(cfg_mod_path)
#         command_names = get_command_names(cfg_mod_path)
#         command_list = ' '.join(command_names)
# 
#         commands = []
#         for cmd in command_names:
#             cmd_cfg, _ = get_command_config(cfg_mod_path, cmd,
#                                             exit_on_failure=False)
# 
#             if cmd_cfg is not None:
#                 command_options = []
#                 command_options.extend(
#                         sorted(['--%s' % p.Name for p in cmd_cfg.inputs]))
#                 opts = ' '.join(command_options)
# 
#                 commands.append(command_fmt % {'command':cmd, 'options':opts})
# 
#         all_commands = ''.join(commands)
#         return {'result':script_fmt % {'driver':driver,
#                                        'commands':all_commands,
#                                        'command_list':command_list}}
# 
# def _get_cfg_module(desc):
#     """Load a module"""
#     mod = importlib.import_module(desc)
#     return mod


import sys
import pyqi
from os import mkdir
from os.path import dirname, join
from shutil import copy, rmtree
from tempfile import mkdtemp
from unittest import TestCase, main
from pyqi.commands.make_bash_completion import BashCompletion, _get_cfg_module
#!/usr/bin/env python
from __future__ import division

#-----------------------------------------------------------------------------
# Copyright (c) 2013, The BiPy Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


__credits__ = ["Daniel McDonald", "Jai Ram Rideout", "Doug Wendel",
               "Greg Caporaso"]


# Path: pyqi/commands/make_bash_completion.py
# class BashCompletion(Command):
#     BriefDescription = "Construct a bash completion script"
#     LongDescription = ("Construct a bash tab completion script that will search"
#         " through available commands and options")
#     
#     CommandIns = ParameterCollection([
#         CommandIn(Name='command_config_module', DataType=str,
#                   Description="CLI command configuration module",
#                   Required=True),
#         CommandIn(Name='driver_name', DataType=str,
#                   Description="name of the driver script", Required=True)
#     ])
# 
#     CommandOuts = ParameterCollection([
#         CommandOut(Name='result', DataType=str,
#                    Description="result bash completion script")
#     ])
# 
#     def run(self, **kwargs):
#         driver = kwargs['driver_name']
#         cfg_mod_path = kwargs['command_config_module']
#         cfg_mod = _get_cfg_module(cfg_mod_path)
#         command_names = get_command_names(cfg_mod_path)
#         command_list = ' '.join(command_names)
# 
#         commands = []
#         for cmd in command_names:
#             cmd_cfg, _ = get_command_config(cfg_mod_path, cmd,
#                                             exit_on_failure=False)
# 
#             if cmd_cfg is not None:
#                 command_options = []
#                 command_options.extend(
#                         sorted(['--%s' % p.Name for p in cmd_cfg.inputs]))
#                 opts = ' '.join(command_options)
# 
#                 commands.append(command_fmt % {'command':cmd, 'options':opts})
# 
#         all_commands = ''.join(commands)
#         return {'result':script_fmt % {'driver':driver,
#                                        'commands':all_commands,
#                                        'command_list':command_list}}
# 
# def _get_cfg_module(desc):
#     """Load a module"""
#     mod = importlib.import_module(desc)
#     return mod


# Path: tests/test_commands/test_make_bash_completion.py
import sys
import pyqi
from os import mkdir
from os.path import dirname, join
from shutil import copy, rmtree
from tempfile import mkdtemp
from unittest import TestCase, main
from pyqi.commands.make_bash_completion import BashCompletion, _get_cfg_module

#!/usr/bin/env python
from __future__ import division

#-----------------------------------------------------------------------------
# Copyright (c) 2013, The BiPy Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


__credits__ = ["Daniel McDonald", "Jai Ram Rideout", "Doug Wendel",
               "Greg Caporaso"]


class BashCompletionTests(TestCase):