• Stars
    star
    348
  • Rank 117,431 (Top 3 %)
  • Language
    C#
  • License
    Other
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Port of docopt to .net

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.

More Repositories

1

docopt

This project is no longer maintained. Please see https://github.com/jazzband/docopt-ng
Python
7,893
star
2

docopt.go

A command-line arguments parser that will make you smile.
Go
1,422
star
3

docopt.cpp

C++11 port of docopt
C++
1,028
star
4

docopt.rs

Docopt for Rust (command line argument parser).
Rust
754
star
5

docopts

Shell interpreter for docopt, the command-line interface description language.
Shell
489
star
6

docopt.rb

Parse command line arguments from nothing more than a usage message
Ruby
461
star
7

docopt.c

C-code generator for docopt language.
Python
316
star
8

docopt.php

Command line argument parser
PHP
298
star
9

docopt.R

Command-line interface description language for R (http://docopt.org)
R
205
star
10

docopt.nim

Command line arguments parser that will make you smile (port of docopt to Nim)
Nim
202
star
11

docopt.java

Java port of docopt
Java
156
star
12

docopt.coffee

docopt - A command line option parser that will make you smile.
CoffeeScript
148
star
13

docopt.hs

A command-line interface description language and parser that will make you smile
Haskell
118
star
14

DocOpt.jl

command line arguments parser
Julia
88
star
15

docopt.clj

Clojure implementation of the docopt language.
Clojure
65
star
16

try.docopt.org

Try out docopt in browser (Flask app running on Heroku)
CSS
61
star
17

docopt.swift

A command-line interface description language and parser that will make you smile http://docopt.org/
Swift
52
star
18

docopt.lua

Lua
37
star
19

docopt.scala

Scala implementation of docopt language
Scala
37
star
20

docopt.fs

Docopt for F#
F#
34
star
21

docopt.d

D
30
star
22

docopt.org

The website
Tcl
25
star
23

docopt.tcl

docopt.org for TCL
Tcl
4
star
24

challenge.docopt.org

Challenge docopt site
Python
3
star
25

docopt.rs-old

New Rust port is here:
Rust
2
star