Skip to content

Makes developing command line tools easier in windows. (.Net). This library is under the WTFPL.

Notifications You must be signed in to change notification settings

jmaxxz/Jmaxxz.Console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 

Repository files navigation

Jmaxxz.Console.Options Jmaxxz.Console.Options Jmaxxz.Console.Options

Join the chat at https://gitter.im/jmaxxz/Jmaxxz.Console

PM> Install-Package Jmaxxz.Console.Options 

Jmaxxz.Console.Shell Jmaxxz.Console.Shell Jmaxxz.Console.Shell

PM> Install-Package Jmaxxz.Console.Shell 

Examples

Let's assume that we have an app that validates json against a json schema. Our app expects 2 files: the first file contains the json and the second file contains the json schema.

Here's an example usage:

$ validate.exe JsonFile.json SchemaFile.schema

You can parse this with the following code:

static void Main(string[] args)
{
  string jsonFile = null;
  string schemaFile = null;

  var options = new Options
  {
    new Option(new string[] {}, s => jsonFile = s, "jsonFile",
      "The file that contains the json you wish to validate"),
    new Option(new string[] {}, s => schemaFile = s, "schemaFile",
      "The file that contains the schema to use for validation")
  };

  if (!options.Parse(args) || jsonFile == null || schemaFile == null)
  {
    options.PrintUsage();
    return;
  }

  // Use jsonFile and schemaFile in your app...
}

If you wish to see the usage run the application and pass it /? or -?:

> validate /?
Usage: validate [-?] <jsonFile> <schemaFile>
================================================================================
Flags                              |  Descriptions
________________________________________________________________________________
-?                                 |  Prints usage for validate.vshost.exe
--help                             |
--------------------------------------------------------------------------------
<jsonFile>                         |  The file that contains the json you wish t
                                   |  o validate
--------------------------------------------------------------------------------
<schemaFile>                       |  The file that contains the schema to use f
                                   |  or validation
--------------------------------------------------------------------------------

License

Jmaxxz.Console is distributed under the following license:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004

Copyright (C) 2004 Sam Hocevar sam@hocevar.net

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.

About

Makes developing command line tools easier in windows. (.Net). This library is under the WTFPL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages