CommandLineKit - A pure Swift library for creating command-line interfaces

Overview

CommandLineKit

A pure Swift library for creating command-line interfaces.

Note: This project is no longer maintained. It's preserved here for historical interest only. Thanks to everyone who contributed!

License

Copyright (c) 2014-18 Ben Gollmer.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Add compatibility with Swift 3 (May 9th) snapshot

    Add compatibility with Swift 3 (May 9th) snapshot

    Here's another take on Swift 3 support, based on your current HEAD.

    I used #if swift(>=3.0) blocks to maintain Swift 2.2 support, but it's apparent that this is a compiler feature and not a preprocessor, e.g. it's not possible to have something like this:

    #if swift(>=3.0)
      private struct StderrOutputStream: OutputStream {
    #else
      private struct StderrOutputStream: OutputStreamType {
    #endif
    

    In that case, I had to duplicate the whole (tiny) struct.

    opened by IngmarStein 11
  • Library not loaded: @rpath/libswiftCore.dylib

    Library not loaded: @rpath/libswiftCore.dylib

    I get this error when running:

    dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Users/USERNAME/Library/Developer/Xcode/DerivedData/LocaleShots-CLI-gncnoendtwgqeofpgzeuqazdgxau/Build/Products/Debug/CommandLine.framework/Versions/A/CommandLine Reason: image not found (lldb)

    There is some help here: http://stackoverflow.com/a/26383255/2183008

    opened by OKNoah 10
  • String Option with default value

    String Option with default value

    Hello,

    I got this code sample:

    let cli = CommandLine()
    
    let deploy = StringOption(shortFlag: "d", longFlag: "deploy",
      helpMessage: "Deploys a plugin, color scheme or template from given directory. Default: Current Directory.")
    
    cli.addOptions(deploy)
    
    do {
      try cli.parse()
    } catch {
      cli.printUsage(error)
      exit(EX_USAGE)
    }
    
    if deploy.value {
        //TODO: empty path => current dir
        print (deploy.value)
    }
    
    

    How can I recognize that the deploy option was called but with an empty value ? I want to support both : Giving a specific directory or leaving the directory path blank which should result in using the current directory. The only way I can think of is to make two options, one StringOption and one BoolOption.

    Is there any better chance to implement this behaviour ?

    Thanks, David

    opened by dehlen 6
  • Update to Swift 1.2

    Update to Swift 1.2

    Hi @jatoben! Updated to Swift 1.2, all tests pass. Here are the changes:

    • countElements() was renamed to count()
    • String.append() doesn't like emoji for some reason now, seems like a bug. So I added a small workaround for that as testEmojiOptions was failing
    opened by beltex 6
  • Can't use with swiftpm at tag v2.2.0

    Can't use with swiftpm at tag v2.2.0

    [some output omitted]

    $ cd /tmp/
    $ git clone https://github.com/jatoben/CommandLine
    $ cd CommandLine
    $ git checkout v2.2.0 -b 2.2.0
    $ swift build
    error: the module at Tests/CommandLine has an invalid name ('CommandLine'): the name of a test module has no ‘Tests’ suffix
    fix: rename the module at ‘Tests/CommandLine’ to have a ‘Tests’ suffix
    

    Please tag the repo more often; the current head works just fine and deserves a 2.2.1 tag!

    opened by glessard 5
  • This project will be archived soon

    This project will be archived soon

    Hi folks,

    If you've been watching this repository, you can tell that I haven't had time to work on this for quite a while. I plan to archive it in the near future to avoid any confusion.

    If anyone has an active fork and would like to pick up the mantle—@benoit-pereira-da-silva, @beltex, or @pdesantis maybe?—I'd be happy to point to your fork(s) for anyone who's looking for a maintained version.

    Thanks to everyone who's contributed!

    opened by jatoben 4
  • Add support for Swift 4

    Add support for Swift 4

    This branch allows for compilation in both Swift 3 and Swift 4. It wraps code that didn't compile in Swift 4 in a #if swift(>=3.2) conditional. This does not change the Swift Language Version build setting, so the project will still compile in Swift 3 by default.

    opened by pdesantis 4
  • Make DEVELOPMENT-SNAPSHOT-2016-03-16-a API changes

    Make DEVELOPMENT-SNAPSHOT-2016-03-16-a API changes

    I made the changes to allow this to work with Swift development snapshot 2016-03-16-a (also working for 2016-03-24-a). This is Swift 3.0 dev.

    This has not been extensively tested, but the little bit I've been using has worked fine. Not sure if you want to support Swift 3.0 yet, but I thought I'd submit this just in case.

    opened by donut 4
  • Rename strayValues to unparsed

    Rename strayValues to unparsed

    strayValues is not a particularly good name. I'm suggesting unparsed. Also, minor tweak to avoid elevating to and flattening from Optional in the parse function.

    opened by glessard 4
  • No Package.swift file found

    No Package.swift file found

    Hi,

    I’m currently using the swift package manager with your repo as a dependency and it seems that there is no 'Package.swift' file added in your version tags (none in the 3 versions). Is this a choice or am I missing something?

    $ swift build Cloning https://github.com/jatoben/CommandLine Using version 2.0.0 of package CommandLine error: No Package.swift file found at: /home/foo/bar/Packages/CommandLine-2.0.0/Package.swift

    Thanks,

    opened by n4ss 4
  • Provide a Default Help Option

    Provide a Default Help Option

    I'm starting a new project that was prototyped in Python, and one of the differences I noticed between Python's ArgParse and CommandLine is the lack of a default help flag.

    To me, at least, having a a help flag included by default would be useful as most applications would benefit from having a simple -h, --help to provide usage and, for the most part, the what the flag needs to do doesn't change (borrowing from ArgParse's help message): "show this help message and exit".

    I made made some modifications to my local repo:

    • Added CommandLine.addHelp(option: BoolOption? = nil) to add a default help option, or override with a custom one. This sets ._helpOption.
    • Updated .parse() to throw a new .HelpOption error. This follows my expected behavior where usage info is printed and then exits.
    • Added a CommandLine.description that is used as the error description

    I'm still messing around with the updates, but am planning on making a pull request if people think it's a good idea.

    My own todo list on this is possibly integrate the description and/ or overriding the default help option into the CommandLine init.

    opened by emorydunn 4
Releases(v2.2.0-pre1)
  • v2.2.0-pre1(Mar 1, 2016)

    Prerelease with Swift 2.2 / Swift Package Manager and Linux support. A few tests still fail on Linux, so use caution.

    Other changes include:

    • Prevent reusing short or long flags (#39, #53)
    • Provide a hook for custom output formatting (#54)
    • Add support for stray values (#56)
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Sep 17, 2015)

    CommandLine v2.0.0 requires Xcode 7 / Swift 2.

    • Use new Swift 2 error handling (#19)
    • Allow callers to specify a destination and error when invoking printUsage() (#20)
    • Options can be specified with either a short flag, long flag, or both (#25)
    • Add wasSet property to Option classes (#26)
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jun 8, 2015)

    CommandLine v1.2.0 requires Xcode 6.3 / Swift 1.2.

    • Add instructions on using frameworks in a command line tool (#11)
    • Update to Swift 1.2 (#12)
    • Fix array index out of range error when a bare - is passed (#16)
    • Add strict parsing mode (#17)
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 4, 2014)

Owner
Ben Gollmer
Ben Gollmer
Simple & Elegant Command Line Interfaces in Swift

An elegant pure Swift library for building command line applications. Features Tons of class, but no classes. 100% organic pure value types. Auto gene

hypertalk 52 Nov 9, 2022
Simple & Elegant Command Line Interfaces in Swift

An elegant pure Swift library for building command line applications. Features Tons of class, but no classes. 100% organic pure value types. Auto gene

hypertalk 52 Nov 9, 2022
Swift-cli - Example of building command-line tools in Swift

swift-cli Example of building command-line tools in Swift Step 1: Create CLI wit

Noah Gift 2 Jan 17, 2022
Command line utility to profile compilation time of Swift project.

xcprofiler Command line utility to profile compilation time of Swift project. This tool is developed in working time for Cookpad. Installation gem ins

Kohki Miki 334 Jan 3, 2023
Josephus - A command line tool to solve Josephus problem in Swift

josephus A command line tool to solve Josephus problem in Swift

Masahiro Oono 0 Jan 25, 2022
Swiftline is a set of tools to help you create command line applications

Swiftline is a set of tools to help you create command line applications. Swiftline is inspired by highline Swiftline contains the following: Colorize

Omar Abdelhafith 1.2k Dec 29, 2022
A Mac command-line tool that generates kick-ass Jamf Pro reports.

KMART - Kick-Ass Mac Admin Reporting Tool A command-line utility generating kick-ass Jamf Pro reports: Features Reporting on the following Jamf Pro ob

Nindi Gill 86 Dec 15, 2022
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

Majd Alfhaily 3k Dec 30, 2022
iOS command-line tool that allows searching and downloading ipa files from the iOS App Store

ipatool for iOS This is a port of Majd Alfhaily's ipatool adapted to run on iOS Build / Installation To build this, make sure you have AppSync install

dan 21 Sep 13, 2022
A nifty command-line tool to customize macOS icons

iconset A nifty command line tool to manage macOS icons iconset is a new command line tool for macOS that allows you to change icons for macOS apps (e

aarnav tale 32 Nov 17, 2022
🕳 A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image.

HolePunch NAME holepunch -- A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image. SYNOPSIS holepu

Yoshimasa Niwa 15 Nov 24, 2022
The best command-line tool to install and switch between multiple versions of Xcode.

The best command-line tool to install and switch between multiple versions of Xcode.

Robots and Pencils 2.3k Jan 9, 2023
Command Line Tool for interacting with MachO binaries on OSX/iOS

inject inject is a tool which interfaces with MachO binaries in order to insert load commands. Below is its help. ➜ ./inject -h OVERVIEW: inject v1.0.

<script>alert('1')</script> 36 Dec 23, 2022
ips2crash is a macOS command line too to convert a .ips file to a legacy .crash log file.

Synopsis ips2crash is a macOS command line too to convert a .ips file to a legacy .crash log file. Motivation It should be possible to read .ips file

null 36 Nov 25, 2022
CookCLI is provided as a command-line tool to make Cook recipe management easier

CookCLI is provided as a command-line tool to make Cook recipe management easier, and enable automation and scripting workflows for the CookLa

null 523 Dec 29, 2022
Adjust the volume from the command line on macOS.

volume Adjust the volume from the command line on macOS. Installation Using Mint: mint install meowmeowmeowcat/[email protected] Usage USAGE: volume <numb

meowmeowcat 3 Sep 28, 2022
A Mac command-line tool that automatically downloads macOS Installers / Firmwares.

MIST - macOS Installer Super Tool A Mac command-line tool that automatically downloads macOS Installers / Firmwares: Features List all available macOS

Nindi Gill 483 Jan 8, 2023
macOS command line tool to return the available disk space on APFS volumes

diskspace Returns available disk space With the various APFS features the value for free disk space returned from tools such as du or df will not be a

Armin Briegel 131 Nov 14, 2022
Command-line utility that checks comments for localizations in iOS interface files (.xib, .storyboard)

Localizations Comments Checker It's really easy to overlook and don't add comment for localization in interface file (.storyboard or .xib). This comma

Bikemap 0 Nov 5, 2021