Coder Social home page Coder Social logo

atifaziz / docopt.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from docopt/docopt.net

0.0 1.0 0.0 19.25 MB

Port of docopt to .net

License: Other

C# 96.95% Python 0.32% HTML 1.50% CSS 0.89% Batchfile 0.02% PowerShell 0.19% Shell 0.02% Dockerfile 0.12%

docopt.net's Introduction

docopt.net is a .NET implementation of docopt

docopt.net is a parser for command-line arguments. It automatically derives the parsing logic from the help text of a program containing its command-line usage in docopt format. docopt is the formalization of conventions that have been used for decades in help messages and man pages for describing a program's interface. Below is an example of such a help text containing the usage for a hypothetical program called Naval Fate:

Naval Fate.

Usage:
  naval_fate.exe ship new <name>...
  naval_fate.exe ship <name> move <x> <y> [--speed=<kn>]
  naval_fate.exe ship shoot <x> <y>
  naval_fate.exe mine (set|remove) <x> <y> [--moored | --drifting]
  naval_fate.exe (-h | --help)
  naval_fate.exe --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --speed=<kn>  Speed in knots [default: 10].
  --moored      Moored (anchored) mine.
  --drifting    Drifting mine.

Usage

The following C# example shows one basic way to use docopt.net:

#nullable enable

using System;
using DocoptNet;

const string usage = @"Naval Fate.

Usage:
  naval_fate.exe ship new <name>...
  naval_fate.exe ship <name> move <x> <y> [--speed=<kn>]
  naval_fate.exe ship shoot <x> <y>
  naval_fate.exe mine (set|remove) <x> <y> [--moored | --drifting]
  naval_fate.exe (-h | --help)
  naval_fate.exe --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --speed=<kn>  Speed in knots [default: 10].
  --moored      Moored (anchored) mine.
  --drifting    Drifting mine.

";

var arguments = new Docopt().Apply(usage, args, version: "Naval Fate 2.0", exit: true)!;
foreach (var (key, value) in arguments)
    Console.WriteLine("{0} = {1}", key, value);

See the documentation for more examples and uses of the docopt.net API.

Documentation

The documentation can be found online at https://docopt.github.io/docopt.net/.

Installation

Install the package in a .NET project using:

dotnet add package docopt.net

Copyright and License

  • © 2012-2014 Vladimir Keleshev [email protected]
  • © 2013 Dinh Doan Van Bien [email protected]
  • © 2021 Atif Aziz
  • Portions © .NET Foundation and Contributors
  • Portions © West Wind Technologies, 2008

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docopt.net's People

Contributors

atifaziz avatar voieducode avatar kyle-fritz-zocdoc avatar smoothdeveloper avatar jefim avatar comandermuffif avatar iwillspeak avatar baruchiro avatar adamchester avatar stoneman avatar forki avatar vvivanloc avatar youssef1313 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.