All Projects → mosop → Cli

mosop / Cli

Licence: mit
Yet another Crystal library for building command-line interface applications.

Programming Languages

crystal
512 projects

Labels

Projects that are alternatives of or similar to Cli

Gay
Colour your text / terminal to be more gay. 🏳️‍🌈
Stars: ✭ 95 (-4.04%)
Mutual labels:  cli
Glom
☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
Stars: ✭ 1,341 (+1254.55%)
Mutual labels:  cli
Tooling
Advancing Node.js as a framework for writing great tools
Stars: ✭ 98 (-1.01%)
Mutual labels:  cli
Synonym
Find synonyms in 15 different languages directly from your terminal.
Stars: ✭ 95 (-4.04%)
Mutual labels:  cli
Texture Synthesis
🎨 Example-based texture synthesis written in Rust 🦀
Stars: ✭ 1,337 (+1250.51%)
Mutual labels:  cli
Gowebdav
A golang WebDAV client library and command line tool.
Stars: ✭ 97 (-2.02%)
Mutual labels:  cli
Proxmove
Migrate virtual machines between different Proxmox VE clusters
Stars: ✭ 94 (-5.05%)
Mutual labels:  cli
Vueneue
DEPRECATED: go to UVue
Stars: ✭ 99 (+0%)
Mutual labels:  cli
Telegram Messages Dump
Command-line tool to dump message history of a Telegram chat.
Stars: ✭ 96 (-3.03%)
Mutual labels:  cli
Terminal layout
The project help you to quickly build layouts in terminal,cross-platform(一个跨平台的命令行ui布局工具)
Stars: ✭ 98 (-1.01%)
Mutual labels:  cli
Generator Ngx Rocket
🚀 Extensible Angular 11+ enterprise-grade project generator
Stars: ✭ 1,329 (+1242.42%)
Mutual labels:  cli
Dart Code Metrics
Software analytics tool that helps developers analyse and improve software quality.
Stars: ✭ 96 (-3.03%)
Mutual labels:  cli
Blockshell
🎉 Minimal Blockchain Learning CLI
Stars: ✭ 1,348 (+1261.62%)
Mutual labels:  cli
Gophie
An Aggregator Engine for searching and downloading movies free - NO ADs!
Stars: ✭ 94 (-5.05%)
Mutual labels:  cli
Transit Map
Generate a schematic map (“metro map”) for a given (transit) network graph using Mixed Integer Programming.
Stars: ✭ 98 (-1.01%)
Mutual labels:  cli
Centerline
Calculate the polygon's centerline
Stars: ✭ 94 (-5.05%)
Mutual labels:  cli
Dotfiles
💻 Use command line interface manager for macOS configuration.
Stars: ✭ 97 (-2.02%)
Mutual labels:  cli
Cryptocurrency Cli
💰 Cryptocurrency Portfolio On The Command Line 💰
Stars: ✭ 99 (+0%)
Mutual labels:  cli
Rundeck Cli
CLI tool for Rundeck
Stars: ✭ 98 (-1.01%)
Mutual labels:  cli
Awesome React Generator
No more clicking around to create files in your react project! Awesome React Generator is Command Line Tool that let's you scaffold your components without leaving your terminal.
Stars: ✭ 98 (-1.01%)
Mutual labels:  cli

Crystal CLI

Yet another Crystal library for building command-line interface applications.

CircleCI

Installation

Add this to your application's shard.yml:

dependencies:
  cli:
    github: mosop/cli

Code Samples

Option Parser

class Hello < Cli::Command
  class Options
    bool "--bye"
    arg "to"
  end

  def run
    if args.bye?
      print "Goodbye"
    else
      print "Hello"
    end
    puts " #{args.to}!"
  end
end

Hello.run %w(world) # prints "Hello, world!"
Hello.run %w(--bye world) # prints "Goodbye, world!"

Subcommand

class Polygon < Cli::Supercommand
  command "triangle", default: true

  class Triangle < Cli::Command
    def run
      puts 3
    end
  end

  class Square < Cli::Command
    def run
      puts 4
    end
  end

  class Hexagon < Cli::Command
    def run
      puts 6
    end
  end
end

Polygon.run %w(triangle) # prints "3"
Polygon.run %w(square)   # prints "4"
Polygon.run %w(hexagon)  # prints "6"
Polygon.run %w()         # prints "3"

Replacing

class New < Cli::Command
  def run
    puts "new!"
  end
end

class Obsolete < Cli::Command
  replacer_command New
end

Obsolete.run # prints "new!"

Inheritance

abstract class Role < Cli::Command
  class Options
    string "--name"
  end
end

class Chase < Cli::Supercommand
  class Mouse < Role
    def run
      puts "#{options.name} runs away."
    end
  end

  class Cat < Role
    def run
      puts "#{options.name} runs into a wall."
    end
  end
end

Chase.run %w(mouse --name Jerry) # prints "Jerry runs away."
Chase.run %w(cat --name Tom)     # prints "Tom runs into a wall."

Help

class Call < Cli::Command
  class Help
    header "Receives an ancient message."
    footer "(C) 20XX mosop"
  end

  class Options
    arg "message", desc: "your message to call them", required: true
    bool "-w", not: "-W", desc: "wait for response", default: true
    help
  end
end

Call.run %w(--help)

Output:

call [OPTIONS] MESSAGE

Receives an ancient message.

Arguments:
  MESSAGE (required)  your message to call them

Options:
  -w          wait for response
              (default: true)
  -W          disable -w
  -h, --help  show this help

(C) 20XX mosop

Versioning

class Command < Cli::Supercommand
  version "1.0.0"

  class Options
    version
  end
end

Command.run %w(-v) # prints 1.0.0

Shell Completion

class TicketToRide < Cli::Command
  class Options
    string "--by", any_of: %w(train plane taxi)
    arg "for", any_of: %w(kyoto kanazawa kamakura)
  end
end

puts TicketToRide.generate_bash_completion
# or
puts TicketToRide.generate_zsh_completion

Usage

require "cli"

and see:

Want to Do

  • Application-Level Logger
  • I18n

Release Notes

See Releases.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].