com.vaadin.sass
Class ArgumentParser

java.lang.Object
  extended by com.vaadin.sass.ArgumentParser

public final class ArgumentParser
extends Object

Argument parsing facility, used internally by SassCompiler.


Nested Class Summary
static class ArgumentParser.Option
          Describes a command-line option.
 
Method Summary
 ArgumentParser.Option defineOption(String... names)
          Define a command-line option.
static ArgumentParser get()
          Get access to the global Argument Parser
 String getInputFile()
          Get the input file argument
 String getOptionValue(String optName)
          Get an option's value.
 String getOutputFile()
          Get the output file argument
 boolean isOptionSet(String optName)
          Check if the user has specified an option on the command line.
 void parse(String[] args)
          Parse the arguments passed to the application
 void printHelp()
          Print help text
 void setHelpText(String help)
          Set help text body.
 void setProgramName(String name)
          Set name of the program (defaults to 'program')
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static final ArgumentParser get()
Get access to the global Argument Parser

Returns:
an argument parser instance

defineOption

public ArgumentParser.Option defineOption(String... names)
Define a command-line option. Returns an ArgumentParser.Option object with fluid API for defining its specifics (like help text, list of valid values/parameters and default value).

Parameters:
names - list of names to associate with this option. One must be defined, any more are optional. Names may NOT overlap; attempting to overwrite a previous name results in an assertion failure.
Returns:
the newly created option object

parse

public void parse(String[] args)
Parse the arguments passed to the application

Parameters:
args - argument array - usually the command line split into its constituent words as passed in to the Java main method.

setProgramName

public void setProgramName(String name)
Set name of the program (defaults to 'program')

Parameters:
name - program name string

setHelpText

public void setHelpText(String help)
Set help text body. Defaults to empty.

Parameters:
help - help text

printHelp

public void printHelp()
Print help text


getInputFile

public String getInputFile()
Get the input file argument

Returns:
a string value

getOutputFile

public String getOutputFile()
Get the output file argument

Returns:
a string value or null if no output file has been specified

isOptionSet

public boolean isOptionSet(String optName)
Check if the user has specified an option on the command line. Can be used for simple boolean checks. This method asserts that an option with the specified name has been added to the argument parser.

Parameters:
optName - name of the option to check
Returns:
true, if the specified option is part of the command line

getOptionValue

public String getOptionValue(String optName)
Get an option's value. If an option has a default value set and the user hasn't explicitly specified a value for this option on the command line, the default value will be returned. Otherwise, the user-set value will be returned. This method asserts that an option with the specified name exists. Note, that not all options support values.

Parameters:
optName - name of the option to check
Returns:
the user-specified value, if the option was set from the command line, or default value (if it has one).


Copyright © 2013–2015 Vaadin. All rights reserved.