<commit_before># CommandLineKit [![Build Status](https://travis-ci.org/IngmarStein/CommandLineKit.svg?branch=master)](https://travis-ci.org/IngmarStein/CommandLineKit)

A pure Swift library for creating command-line interfaces.

*Note: CommandLineKit `master` requires Xcode 10.2 / Swift 5.0. If you're using older versions of Swift, please check out the [earlier releases](https://github.com/IngmarStein/CommandLineKit/releases).*

## Usage

CommandLine aims to have a simple and self-explanatory API.

```swift
import CommandLineKit

let cli = CommandLineKit.CommandLine()

let filePath = StringOption(shortFlag: "f", longFlag: "file", required: true,
  helpMessage: "Path to the output file.")
let compress = BoolOption(shortFlag: "c", longFlag: "compress",
  helpMessage: "Use data compression.")
let help = BoolOption(shortFlag: "h", longFlag: "help",
  helpMessage: "Prints a help message.")
let verbosity = CounterOption(shortFlag: "v", longFlag: "verbose",
  helpMessage: "Print verbose messages. Specify multiple times to increase verbosity.")

cli.addOptions(filePath, compress, help, verbosity)

do {
  try cli.parse()
} catch {
  cli.printUsage(error)
  exit(EX_USAGE)
}

print("File path is \(filePath.value!)")
print("Compress is \(compress.value)")
print("Verbosity is \(verbosity.value)")
```

See `Option.swift` for additional Option types.

To use CommandLineKit in your project, add it to your workspace, then add CommandLineKit.framework to the __Build Phases / Link Binary With Libraries__ setting of your target.

If you use CocoaPods, just add `pod 'CommandLineKit'` to your `Podfile`.

If you are building a command-line tool and need to embed this and other frameworks to it, follow the steps in http://colemancda.github.io/2015/02/12/embedded-swift-frameworks-osx-command-line-tools/ to link Swift frameworks to your command-line tool.

If you are building a standalone command-line tool, you'll need to add the CommandLineKit source files directly to your target, because Xcode [can't yet build static libraries that contain Swift code](https://github.com/ksm/SwiftInFlux#static-libraries).
<commit_msg>Update README wrt. Swift static libraries<commit_after># CommandLineKit [![Build Status](https://travis-ci.org/IngmarStein/CommandLineKit.svg?branch=master)](https://travis-ci.org/IngmarStein/CommandLineKit)

A pure Swift library for creating command-line interfaces.

*Note: CommandLineKit `master` requires Xcode 10.2 / Swift 5.0. If you're using older versions of Swift, please check out the [earlier releases](https://github.com/IngmarStein/CommandLineKit/releases).*

## Usage

CommandLine aims to have a simple and self-explanatory API.

```swift
import CommandLineKit

let cli = CommandLineKit.CommandLine()

let filePath = StringOption(shortFlag: "f", longFlag: "file", required: true,
  helpMessage: "Path to the output file.")
let compress = BoolOption(shortFlag: "c", longFlag: "compress",
  helpMessage: "Use data compression.")
let help = BoolOption(shortFlag: "h", longFlag: "help",
  helpMessage: "Prints a help message.")
let verbosity = CounterOption(shortFlag: "v", longFlag: "verbose",
  helpMessage: "Print verbose messages. Specify multiple times to increase verbosity.")

cli.addOptions(filePath, compress, help, verbosity)

do {
  try cli.parse()
} catch {
  cli.printUsage(error)
  exit(EX_USAGE)
}

print("File path is \(filePath.value!)")
print("Compress is \(compress.value)")
print("Verbosity is \(verbosity.value)")
```

See `Option.swift` for additional Option types.

To use CommandLineKit in your project, add it to your workspace, then add CommandLineKit.framework to the __Build Phases / Link Binary With Libraries__ setting of your target.

If you use CocoaPods, just add `pod 'CommandLineKit'` to your `Podfile`.

If you are building a command-line tool and need to embed this and other frameworks to it, follow the steps in http://colemancda.github.io/2015/02/12/embedded-swift-frameworks-osx-command-line-tools/ to link Swift frameworks to your command-line tool.

If you are building a standalone command-line tool, you'll need to use CommandLineKit as a static library which requires at least Xcode 9 beta 4.  If you use CocoaPods 1.5.0 or newer, this can be achieved by not specifying `use_frameworks!`.
{'fraction_non_alphanumeric': 0.10622367805334582, 'fraction_numerical': 0.007253158633598503, 'mean_word_length': 5.151079136690647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6970774', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1260, 'n_words': 462}