The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::vaporcalc::Role::UI::ParseCmd

SYNOPSIS

  package MyCmdParser;
  use Moo;
  has subject_list => (
    is      => 'ro',
    builder => sub {
      [ 'nic base', 'flavor' ]
    },
  );
  with 'App::vaporcalc::Role::UI::ParseCmd';

  package main;
  my $parser = MyCmdParser->new;
  # Same as:
  # my $result = $parser->parse_cmd("nic base set 100");
  my $result = $parser->parse_cmd("set nic base 100");
  my $subj = $result->subject;  # 'nic base'
  my $verb = $result->verb;     # 'set'
  my $params = $result->params; # params as a List::Objects::WithUtils::Array

DESCRIPTION

A Moo::Role for parsing command strings based on a list of valid subjects (command targets).

REQUIRES

subject_list

The subject_list method is expected to return an ARRAY or ARRAY-type object containing a list of valid subjects.

METHODS

parse_cmd

Given a string, returns an inflated List::Objects::WithUtils::Hash with subject, verb, and params accessors (see SYNOPSIS).

Used by App::vaporcalc::CmdEngine to parse vaporcalc commands.

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>