Handle the command line options
499911
def cli_opts():
    
    parser = argparse.ArgumentParser()

    parser.add_argument(
        "--homeassistant-config",
        type=str,
        required=False,
        dest="config",
        help="Create configuration section for home assistant",)
    parser.add_argument(
        "-f",
        "--filter",
        type=str,
        required=False,
        dest="filter",
        help="Ignore events related with these devices",)
    parser.add_argument(
        "-o",
        "--output",
        type=str,
        required=False,
        dest="output",
        help="Send output to file",)
    parser.add_argument(
        "-v", "--verbose",
        action="store_true",
        dest="verbose",
        help="Verbose output",)
    parser.add_argument('device')

    return parser.parse_args()
360789
def _process_option(self, tsocket, command, option):
        
        if option == ECHO:
            tsocket.sendall(IAC + DO + ECHO)
        elif command in (DO, DONT):
            tsocket.sendall(IAC + WONT + option)
        elif command in (WILL, WONT):
            tsocket.sendall(IAC + DONT + option)
811453
def execute(self):
        
        #Initialize the option parser
        parser = LaxOptionParser(
            usage="%prog subcommand [options] [args]",
            option_list=BaseCommand.option_list #This will define what is allowed input to the parser (ie --settings=)
        )

        #Parse the options
        options, args = parser.parse_args(self.argv)
        #Handle --settings and --pythonpath properly
        options = handle_default_options(options)

        try:
            #Get the name of the subcommand
            subcommand = self.argv[1]
        except IndexError:
            #If the subcommand name cannot be found, set it to help
            subcommand = 'help'

        #If the subcommand is help, print the usage of the parser, and available command names
        if subcommand == 'help':
            if len(args) <= 2:
                parser.print_help()
                sys.stdout.write(self.help_text + '\n')
        else:
            #Otherwise, run the given command
            self.fetch_command(subcommand).run_from_argv(self.argv)
1325741
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]:
    
    return options.parse_command_line(args, final=final)
1245374
function execute(args) {
    try {
        const currentOptions = options.parse(args)
        return executeOptions(currentOptions)
    } catch (error) {
        console.error(error.message)
        return 1
    }
}
303256
def main():
    """"""
    # Initialize logging to the terminal.
    coloredlogs.install()
    # Prepare for command line argument parsing.
    action = show_matching_entry
    program_opts = dict(exclude_list=[])
    show_opts = dict(filters=[], use_clipboard=is_clipboard_supported())
    verbosity = 0
    # Parse the command line arguments.
    try:
        options, arguments = getopt.gnu_getopt(
            sys.argv[1:],
            "elnp:f:x:vqh",
            ["edit", "list", "no-clipboard", "password-store=", "filter=", "exclude=", "verbose", "quiet", "help"],
        )
        for option, value in options:
            if option in ("-e", "--edit"):
                action = edit_matching_entry
            elif option in ("-l", "--list"):
                action = list_matching_entries
            elif option in ("-n", "--no-clipboard"):
                show_opts["use_clipboard"] = False
            elif option in ("-p", "--password-store"):
                stores = program_opts.setdefault("stores", [])
                stores.append(PasswordStore(directory=value))
            elif option in ("-f", "--filter"):
                show_opts["filters"].append(value)
            elif option in ("-x", "--exclude"):
                program_opts["exclude_list"].append(value)
            elif option in ("-v", "--verbose"):
                coloredlogs.increase_verbosity()
                verbosity += 1
            elif option in ("-q", "--quiet"):
                coloredlogs.decrease_verbosity()
                verbosity -= 1
            elif option in ("-h", "--help"):
                usage(__doc__)
                return
            else:
                raise Exception("Unhandled option! (programming error)")
        if not (arguments or action == list_matching_entries):
            usage(__doc__)
            return
    except Exception as e:
        warning("Error: %s", e)
        sys.exit(1)
    # Execute the requested action.
    try:
        show_opts["quiet"] = verbosity < 0
        kw = show_opts if action == show_matching_entry else {}
        action(QuickPass(**program_opts), arguments, **kw)
    except PasswordStoreError as e:
        # Known issues don't get a traceback.
        logger.error("%s", e)
        sys.exit(1)
    except KeyboardInterrupt:
        # If the user interrupted an interactive prompt they most likely did so
        # intentionally, so there's no point in generating more output here.
        sys.exit(1)
587635
def handle(self):
        ""
        if self.TELNET_ISSUE:
            self.writeline(self.TELNET_ISSUE)
        if not self.authentication_ok():
            return
        if self.DOECHO:
            self.writeline(self.WELCOME)

        self.session_start()
        while self.RUNSHELL:
            raw_input = self.readline(prompt=self.PROMPT).strip()
            self.input = self.input_reader(self, raw_input)
            self.raw_input = self.input.raw
            if self.input.cmd:
                cmd = self.input.cmd.upper()
                params = self.input.params
                if self.COMMANDS.has_key(cmd):
                    try:
                        self.COMMANDS[cmd](params)
                    except:
                        log.exception('Error calling %s.' % cmd)
                        (t, p, tb) = sys.exc_info()
                        if self.handleException(t, p, tb):
                            break
                else:
                    self.writeerror("Unknown command '%s'" % cmd)
        log.debug("Exiting handler")
814773
def handle_command_line():
    """"""
    phrase = ' '.join(sys.argv[1:]) or 'random'

    try:
        giphy = get_random_giphy(phrase)
    except ValueError:
        sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
        sys.exit(1)

    display(fetch_image(giphy))
284834
def handle(self, *args, **options):
        
        if options["sub_command"] == "add":
            self.handle_add(options)
        elif options["sub_command"] == "update":
            self.handle_update(options)
        elif options["sub_command"] == "details":
            self.handle_details(options["username"])
        elif options["sub_command"] == "list":
            self.handle_list(options["all"], options["csv"])
580882
def handle(self, *file_paths, **options):
        
        import os

        for file_path in file_paths:
            if not os.path.isfile(file_path):
                print("File %s not found." % file_path)
                continue
            f = open(file_path, 'r')
            data = f.readlines()
            f.close()

            self.parse_lines(data)
500551
def go(argv, opts, config)
      opts.banner = "Usage: #{syntax}"
      process_options(opts, config)
      add_default_options(opts)

      if argv[0] && cmd = commands[argv[0].to_sym]
        logger.debug "Found subcommand '#{cmd.name}'"
        argv.shift
        cmd.go(argv, opts, config)
      else
        logger.debug "No additional command found, time to exec"
        self
      end
    end
77755
def _process_option(self, tsocket, command, option):
        
        if command == DO and option == TTYPE:
            tsocket.sendall(IAC + WILL + TTYPE)
            tsocket.sendall(IAC + SB + TTYPE + b"\0" + b"xterm" + IAC + SE)
        elif command in (DO, DONT):
            tsocket.sendall(IAC + WONT + option)
        elif command in (WILL, WONT):
            tsocket.sendall(IAC + DONT + option)
1288866
def handle(self, *arguments, **options):
        
        self.arguments = arguments
        self.options = options
        self.arguments = self.parse_arguments(arguments)
        self.options = self.parse_options(options)
        
        for name in self.get_actions():
            validate = getattr(self, "validate_{name:s}".format(
                name=name), None)
            if validate is not None and isinstance(validate, collections.Callable):
                validate(*arguments, **options)
        for name in self.get_actions():
            handle = getattr(self, "handle_{name:s}".format(
                name=name), None)
            if handle is not None and isinstance(handle, collections.Callable):
                handle(*self.arguments, **self.options)
182360
def handle_argv(self, prog_name, argv):
        
        options, args = self.parse_options(prog_name, argv)
        return self.run(*args, **vars(options))
972258
def handle(self, *args, **options):
        
        self.pre_process(self.repo)
        self.handle_repo(self.repo, *args, **options)
        self.post_process(self.repo, **options)
993365
def command *args, &block
       if event? :PRESS
         bind :PRESS, *args, &block
       else
         bind :CHANGED, *args, &block
       end
     end
1244525
def run(*args)
      stdin = nil
      cmd = SysCmd.command name do
        args.each do |arg|
          case arg
          when Hash
            arg.each do |key, value|
              next if value.nil?
              case value
              when Array
                value = value*","
              when String
                if value.include?("\n")
                  raise "Cannot pass multiple options through STDIN" if stdin
                  stdin = Support.unindent(value)
                  value = "-"
                  input stdin
                end
              end
              option key.to_s, equal_value: value
            end
          else
            option arg
          end
        end
      end
      if @context
        @context.execute cmd
      end
      cmd
    end