promotional bannermobile promotional banner

ArgEngine

Abandoned
The GetOpt-like tool for Bukkit plugins.

ArgEngine

Introduction

Hello developers, you may know GetOpt from the glibc. A useful framework which provides the CLI parameter parsing. Now with ArgEngine this tool meets Bukkit. For users which already have used GetOpt I shall say that it works very different.

How to use it?

First you have to configure the general parsing options.

OptionsSheet mySheet = new OptionsSheet();  // This is used to hold your configuration
mySheet.exceptionOnUnknown = false;  // Set the options as you need them
OptionsSheetEntry newEntry = mySheet.new OptionsSheetEntry();  // Create a new entry
newEntry.name = "block";  // Set a name for this option
newEntry.type = OptionType.KEY_VALUE_PAIR;  // Set a type
newEntry.required = true;  // Set this option to reqiured
testSheet.addEntry(newEntry);  // Add the option to your Sheet

The exceptionOnUnkown switch and the other fields are documented in the source code which you can also download from here. I won't explain every option here.
If you don't want to set the configuration up like this you can create an OptionsSheet from a file.

OptionsSheet mySheet = new OptionsSheet();
mySheet.load(new FileReader("path/to/file"));

Check Configuration for details.
Now you have a setup which you can use to use the parser.

public boolean onCommand(CommandSender cSender, Command cmd, String label, String args[]) {
    try {
        Options result = ArgEngine.process(args, mySheet);   // Pass your arguments and parser setup
        result.getString("block");   // Get the value for this option
    } catch (RequirementUnsatisfiedException | TooManyArgumentsException exc) {
        // Handle as you like
    }
    return true;
}

Also check Source and Eclipse if you use Eclipse.

Features

+ Option types: BOOLEAN, KEY_VALUE_PAIR, SELECTION, SETTING, ANY
+ A string like

--message "Hello you!" -other

will see Hello you! as 1 argument not as 2
+ Throwing exceptions on specific argument faults.
+ An option set to "yes" and read as boolean will return true (no => false)
+ An OptionsSheet can be loaded from a file or string

How does the user use it?

There are two parsing options. You can select one of them by setting the linuxLike option in you OptionsSheet

  1. like the getopt parser (will be implemented later)
  2. with my special method (default)

My special method

User entryInterpretationOptionType
+opt
The key opt is set to trueBOOLEAN
-opt
The key opt is set to falseBOOLEAN
--opt value
The key opt is set to "value"KEY_VALUE_PAIR or SELECTION
opt
The key opt is setANY
--opt=value
The key opt is set to "value"KEY_VALUE_PAIR or SELECTION

The ArgEngine Team

profile avatar
  • 4
    Projects
  • 3.4K
    Downloads

More from _ForgeUser12077619

  • Building Detector project image

    Building Detector

    • 387
    • Bukkit Plugins

    Building Detector

    • 387
    • August 10, 2014
    • Bukkit Plugins
    • +1
  • CmdCatch project image

    CmdCatch

    • 2.0K
    • Bukkit Plugins

    Catch dispatched commands

    • 2.0K
    • December 22, 2013
    • Bukkit Plugins
    • +1
  • BukkiSH project image

    BukkiSH

    • 0
    • Bukkit Plugins

    You bash-like shell for bukkit.

    • 0
    • September 18, 2013
    • Bukkit Plugins
  • Building Detector project image

    Building Detector

    • 387
    • Bukkit Plugins

    Building Detector

    • 387
    • August 10, 2014
    • Bukkit Plugins
    • +1
  • CmdCatch project image

    CmdCatch

    • 2.0K
    • Bukkit Plugins

    Catch dispatched commands

    • 2.0K
    • December 22, 2013
    • Bukkit Plugins
    • +1
  • BukkiSH project image

    BukkiSH

    • 0
    • Bukkit Plugins

    You bash-like shell for bukkit.

    • 0
    • September 18, 2013
    • Bukkit Plugins