class CliGen::Arg

Overview

This class serves as a "argument wrapper" to force a fail-fast approach to arg-parsing.

It wraps around the argument + index of the argument to do state tracking and ensure that each argument is only processed once (plus allows for easier filtering of processed arguments to avoid having to do index math)

args.reject(&.processed?) # returns the args that haven't been processed yet

It expects each argument to only be processed once and will force a raise if the argument has Arg#processed called a second time. This is to force the developer (me) to fix any processing issues during the development of this framework.

Defined in:

cligen/arg.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(value : String, index : Int32) #

Instance Method Detail

def index : Int32 #

The index of the argument in the array it was in


def processed #

This serves as a trigger that tells the object that it has been processed

This will raise an exception if it is re-called after already having been processed.


def processed? : Bool #

The "flag"/variable that tracks is the Arg has been processed yet


def value : String #

The raw string argument provided from the user