Skip to content

Commit

Permalink
Rename to Samovar.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 23, 2016
1 parent 2ac6787 commit 33c4937
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in flopp.gemspec
# Specify your gem's dependencies in samovar.gemspec
gemspec

group :test do
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Flopp
# Samovar

![Teapot](teapot.png)

Flopp is a modern framework for building command-line tools and applications. It provides a declarative class-based DSL for building command-line parsers that include automatic documentation generation `--help`. It helps you keep your functionality clean and isolated where possible.
Samovar is a modern framework for building command-line tools and applications. It provides a declarative class-based DSL for building command-line parsers that include automatic documentation generation `--help`. It helps you keep your functionality clean and isolated where possible.

[![Build Status](https://secure.travis-ci.org/ioquatix/flopp.svg)](http://travis-ci.org/ioquatix/flopp)
[![Code Climate](https://codeclimate.com/github/ioquatix/flopp.svg)](https://codeclimate.com/github/ioquatix/flopp)
[![Coverage Status](https://coveralls.io/repos/ioquatix/flopp/badge.svg)](https://coveralls.io/r/ioquatix/flopp)
[![Build Status](https://secure.travis-ci.org/ioquatix/samovar.svg)](http://travis-ci.org/ioquatix/samovar)
[![Code Climate](https://codeclimate.com/github/ioquatix/samovar.svg)](https://codeclimate.com/github/ioquatix/samovar)
[![Coverage Status](https://coveralls.io/repos/ioquatix/samovar/badge.svg)](https://coveralls.io/r/ioquatix/samovar)

## Motivation

I've been using [Trollop](https://github.com/ManageIQ/trollop) and while it's not bad, it's hard to use for sub-commands in a way that generates nice documentation. It also has pretty limited support for complex command lines (e.g. nested commands, splits, matching tokens, etc). Flopp is a high level bridge between the command line and your code: it generates decent documentation, maps nicely between the command line syntax and your functions, and supports sub-commands using classes which are easy to compose.
I've been using [Trollop](https://github.com/ManageIQ/trollop) and while it's not bad, it's hard to use for sub-commands in a way that generates nice documentation. It also has pretty limited support for complex command lines (e.g. nested commands, splits, matching tokens, etc). Samovar is a high level bridge between the command line and your code: it generates decent documentation, maps nicely between the command line syntax and your functions, and supports sub-commands using classes which are easy to compose.

One of the other issues I had with existing frameworks is testability. Most frameworks expect to have some pretty heavy logic directly in the binary executable, or at least don't structure your code in a way which makes testing easy. Flopp structures your command processing logic into classes which can be easily tested in isolation, which means that you can mock up and [spec your command-line executables easily](https://github.com/ioquatix/teapot/blob/master/spec/teapot/command_spec.rb).
One of the other issues I had with existing frameworks is testability. Most frameworks expect to have some pretty heavy logic directly in the binary executable, or at least don't structure your code in a way which makes testing easy. Samovar structures your command processing logic into classes which can be easily tested in isolation, which means that you can mock up and [spec your command-line executables easily](https://github.com/ioquatix/teapot/blob/master/spec/teapot/command_spec.rb).

## Installation

Add this line to your application's Gemfile:

gem 'flopp'
gem 'samovar'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flopp
$ gem install samovar

## Usage

The best example of a working Flopp command line is probably [Teapot](https://github.com/ioquatix/teapot/blob/master/lib/teapot/command.rb). Please feel free to submit other examples and I will link to them here.
The best example of a working Samovar command line is probably [Teapot](https://github.com/ioquatix/teapot/blob/master/lib/teapot/command.rb). Please feel free to submit other examples and I will link to them here.

## Contributing

Expand All @@ -42,7 +42,7 @@ The best example of a working Flopp command line is probably [Teapot](https://gi

### Future Work

One area that I'd like to work on is line-wrapping. Right now, line wrapping is done by the terminal which is a bit ugly in some cases. There is a [half-implemented elegant solution](lib/flopp/output/line_wrapper.rb).
One area that I'd like to work on is line-wrapping. Right now, line wrapping is done by the terminal which is a bit ugly in some cases. There is a [half-implemented elegant solution](lib/samovar/output/line_wrapper.rb).

## License

Expand Down
10 changes: 5 additions & 5 deletions flopp.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'flopp/version'
require 'samovar/version'

Gem::Specification.new do |spec|
spec.name = "flopp"
spec.version = Flopp::VERSION
spec.name = "samovar"
spec.version = Samovar::VERSION
spec.authors = ["Samuel Williams"]
spec.email = ["samuel.williams@oriontransfer.co.nz"]

spec.summary = %q{Flopp is a flexible option parser excellent support for sub-commands and help documentation.}
spec.homepage = "https://github.com/ioquatix/flopp"
spec.summary = %q{Samovar is a flexible option parser excellent support for sub-commands and help documentation.}
spec.homepage = "https://github.com/ioquatix/samovar"
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
Expand Down
3 changes: 0 additions & 3 deletions lib/flopp.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/samovar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

require_relative 'samovar/version'
require_relative 'samovar/command'
2 changes: 1 addition & 1 deletion lib/flopp/command.rb → lib/samovar/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

require_relative 'output'

module Flopp
module Samovar
class IncompleteParse < StandardError
end

Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/flags.rb → lib/samovar/flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class Flags
def initialize(text)
@text = text
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/many.rb → lib/samovar/many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class Many
def initialize(key, description, stop: /^-/)
@key = key
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/nested.rb → lib/samovar/nested.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class Nested
def initialize(name, commands, key: :command)
@name = name
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/one.rb → lib/samovar/one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class One
def initialize(key, description, pattern: //)
@key = key
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/options.rb → lib/samovar/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require_relative 'flags'

module Flopp
module Samovar
class Option
def initialize(flags, description, key: nil, default: nil, value: nil)
@flags = Flags.new(flags)
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/output.rb → lib/samovar/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'mapping/model'
require 'rainbow'

module Flopp
module Samovar
module Output
class Header
def initialize(name, object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
module Output
# This is an incomplete implementation of an automatic line wrapping output buffer which handles any kind of output, provided it has special wrapping markers.
class LineWrapping
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/split.rb → lib/samovar/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class Split
def initialize(key, description, marker: '--')
@key = key
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/table.rb → lib/samovar/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

module Flopp
module Samovar
class Table
def initialize
@rows = []
Expand Down
2 changes: 1 addition & 1 deletion lib/flopp/version.rb → lib/samovar/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Flopp
module Samovar
VERSION = "1.0.1"
end
8 changes: 4 additions & 4 deletions spec/flopp_spec.rb → spec/samovar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

require 'flopp'
require 'samovar'
require 'stringio'

module Command
class Bottom < Flopp::Command
class Bottom < Samovar::Command
self.description = "Create a new teapot package using the specified repository."

one :project_name, "The name of the new project in title-case, e.g. 'My Project'."
many :packages, "Any additional packages you'd like to include in the project."
split :argv, "Additional arguments to be passed to the sub-process."
end

class Top < Flopp::Command
class Top < Samovar::Command
self.description = "A decentralised package manager and build tool."

options do
Expand All @@ -27,7 +27,7 @@ class Top < Flopp::Command
end
end

describe Flopp do
describe Samovar do
it "should parse a simple command" do
top = Command::Top.parse(["-c", "path", "bottom", "foobar", "A", "B", "--", "args", "args"])

Expand Down

0 comments on commit 33c4937

Please sign in to comment.