<commit_before>'''
Define the command bar
'''
# Import third party libs
import urwid


class CommandBar(object):
    '''
    The object to manage the command bar
    '''
    def __init__(self, opts):
        self.opts = opts
        self.tgt_txt = urwid.Text('Target')
        self.tgt_edit = urwid.Edit()
        self.fun_txt = urwid.Text('Function')
        self.fun_edit = urwid.Edit()
        self.arg_txt = urwid.Text('Arguments')
        self.arg_edit = urwid.Edit()
        self.go_button = urwid.Button('GO!')
        self.grid = urwid.GridFlow(
                [self.tgt_txt,
                 self.tgt_edit,
                 self.fun_txt,
                 self.fun_edit,
                 self.arg_txt,
                 self.arg_edit,
                 self.go_button],
                cell_width=10,
                h_sep=1,
                v_sep=1,
                align='left')<commit_msg>Add functionality to the go button<commit_after>'''
Define the command bar
'''
# Import third party libs
import urwid

# Import salt libs
import salt.client


class CommandBar(object):
    '''
    The object to manage the command bar
    '''
    def __init__(self, opts):
        self.opts = opts
        self.local = salt.client.LocalClient(mopts=opts)
        self.tgt_txt = urwid.Text('Target')
        self.tgt_edit = urwid.Edit()
        self.fun_txt = urwid.Text('Function')
        self.fun_edit = urwid.Edit()
        self.arg_txt = urwid.Text('Arguments')
        self.arg_edit = urwid.Edit()
        self.go_button = urwid.Button('GO!', self.run_command)
        self.grid = urwid.GridFlow(
                [self.tgt_txt,
                 self.tgt_edit,
                 self.fun_txt,
                 self.fun_edit,
                 self.arg_txt,
                 self.arg_edit,
                 self.go_button],
                cell_width=10,
                h_sep=1,
                v_sep=1,
                align='left')

    def run_command(self, button, user_data):
        '''
        Execute the corresponding salt command
        '''
        tgt = self.tgt_edit.get_edit_text()
        fun = self.fun_edit.get_edit_text()
        args = self.arg_edit.get_edit_text().split()
        self.local.cmd_async(tgt, fun, args)
{'fraction_non_alphanumeric': 0.10907465355386678, 'fraction_numerical': 0.003576218149307108, 'mean_word_length': 1.6548042704626333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5767795', 'n_tokens_mistral': 697, 'n_tokens_neox': 678, 'n_words': 134}