netromdk / slacker

Slacker - Easy access to the Slack API and admin of workspaces/teams.
MIT License
14 stars 0 forks source link

Support command arguments #19

Closed netromdk closed 6 years ago

netromdk commented 6 years ago

Each command should have it's own command parser, like argparse.

The first input sequence until whitespace is the command. If it matches a command in the registrar, and there is further input text, then use that command's argument parser. If no argument parser is defined it means that it doesn't accept arguments.

Extend Command with the following per default:

def parse_args(self, args):
  return None

If defining arguments for a command:

def parse_args(self, args):
  parser = argparse.ArgumentParser()
  # .. define arguments ..
  return parser.parse_args(args)

Example of usage:

args = cmd.parse_args(the_input.split())
cmd.action(args)
netromdk commented 6 years ago

Implemented in f15082900f32b279ede480896bb2dddf169ccd6e but requires #15 to be merged first.