Docopt.swift
A command-line interface description language and parser that will make you smile http://docopt.org/
Install / Use
/learn @docopt/Docopt.swiftREADME
docopt.swift is a Swift port of docopt
docopt.swift helps you create most beautiful command-line interfaces easily:
Swift:
let doc : String = """
Not a serious example.
Usage:
calculator_example.py <value> ( ( + | - | * | / ) <value> )...
calculator_example.py <function> <value> [( , <value> )]...
calculator_example.py (-h | --help)
Examples:
calculator_example.py 1 + 2 + 3 + 4 + 5
calculator_example.py 1 + 2 '*' 3 / 4 - 5 # note quotes around '*'
calculator_example.py sum 10 , 20 , 30 , 40
Options:
-h, --help
"""
var args = Process.arguments
args.removeAtIndex(0) // arguments[0] is always the program_name
let result = Docopt.parse(doc, argv: args, help: true, version: "1.0")
println("Docopt result: \(result)")
Objective-C:
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
arguments = arguments.count > 1 ? [arguments subarrayWithRange:NSMakeRange(1, arguments.count - 1)] : @[];
NSDictionary *result = [Docopt parse:doc argv:arguments help:YES version:@"1.0" optionsFirst:NO];
NSLog(@"Docopt result:\n%@", result);
Installation
Swift:
- Check out
docopt.swift - Add
docoptfolder to your project
Swift Package Manager:
.package(url: "https://github.com/docopt/docopt.swift", from: "0.6.6"),
Objective-C:
- Check out
docopt.swift - Build
Docopttarget - Add
Docopt.frameworkto your project
License
docopt.swift is released under the MIT License.
Related Skills
node-connect
352.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
