Skip to content

Commit

Permalink
- Remove Colsole and Exec modules
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBen committed Sep 27, 2021
1 parent c95b759 commit 06f37bf
Show file tree
Hide file tree
Showing 44 changed files with 173 additions and 316 deletions.
17 changes: 8 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
source "https://rubygems.org"

gemspec
gem 'runfile-tasks'
gem 'cucumber'
gem 'rspec-expectations'
gem 'rdoc'
gem 'similar_text'
gem 'byebug'
gem 'colsole'

group :development do
gem 'runfile-tasks'
gem 'cucumber'
gem 'rspec-expectations'
gem 'rdoc'
gem 'similar_text'
gem 'byebug'
end
gemspec
4 changes: 4 additions & 0 deletions Runfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "runfile-tasks"
require "yaml"
require "colsole"
require "byebug"

include Colsole

title "Runfile Runfile"
summary "Runfile tasks for building the Runfile gem"
Expand Down
1 change: 0 additions & 1 deletion bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require 'runfile'
# for dev
# require File.dirname(__FILE__) + "/../lib/runfile"

include Colsole
include Runfile::DSL

Runfile::Runner.instance.execute ARGV
1 change: 0 additions & 1 deletion bin/run!
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require 'runfile'
# for dev
# require File.dirname(__FILE__) + "/../lib/runfile"

include Colsole
include Runfile::DSL

Runfile::Runner.instance.execute ARGV, false
2 changes: 1 addition & 1 deletion examples/a_minimal/Runfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
usage "greet <name>"
help "Say hello to <name>"
action :greet do |args|
say "Hello #{args['<name>']}"
puts "Hello #{args['<name>']}"
end
4 changes: 4 additions & 0 deletions examples/b_basic/Runfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# include colsole, for easy color output
require 'colsole'
include Colsole

# define the application itself
title "Runner"
summary "The first ever Runfile program"
Expand Down
4 changes: 4 additions & 0 deletions examples/c_documented/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# each Runfile may have a summary and a version. Both are optional.
#---

# optionally, include colsole, for easy color output (for the method 'say')
require 'colsole'
include Colsole

# title sets the title of the application (default: 'Runfile').
title "Runner"

Expand Down
12 changes: 6 additions & 6 deletions examples/d_realistic/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ usage "compile <source> <dest> [--quick]"
help "Compile <source> to <dest>"
option "-q --quick", "Make everything quicker"
action :compile do |args|
say "!txtred!Compiling #{args['<source>']}... "
puts "Compiling #{args['<source>']}... "
sleep 3 unless args['--quick']
say "!txtgrn!done"
say "Output is saved to #{args['<dest>']}"
puts "done"
puts "Output is saved to #{args['<dest>']}"
end

usage "download <url> [<outfile>] [-CIq]"
help "Download HTML and images from <url>. Use the --quick flag to download quickly."
option "-C --no-cache", "Bypass cache"
option "-I --no-img" , "Do not download images"
action :download do |args|
say "!txtred!Downloading #{args['<url>']}... "
puts "Downloading #{args['<url>']}... "
sleep 3 unless args['--quick']
say "!txtgrn!downloaded"
say "!txtred!cache was bypassed" if args['--no-cache']
puts "downloaded"
puts "cache was bypassed" if args['--no-cache']
end
7 changes: 3 additions & 4 deletions examples/e_optionals/Runfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
action :explain do
say "Actions without arguments do not need 'usage'"
puts "Actions without arguments do not need 'usage'"
end

usage "greet <name>"
action :greet do |args|
say "Hello #{args['<name>']}"
puts "Hello #{args['<name>']}"
end

help "Say bye"
action :bye do
say "Here we added help to an action without usage... "
say "!txtgrn!and it works!"
puts "Here we added help to an action without usage... "
end

12 changes: 6 additions & 6 deletions examples/f_namespace/Runfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# this is a globel action
action :greet do
say "Hello"
puts "Hello"
end

# define a "super command" (namespace).
Expand All @@ -11,24 +11,24 @@ command "make"
# will be stored as ":make_custard".
usage "custard"
action :custard do
say "Making custard..."
puts "Making custard..."
end

usage "jam"
action :jam do
say "Making jam..."
puts "Making jam..."
end

usage "meat [--mix]"
option "--mix", "Mix all the ingredients. Good."
action :meat do |args|
say "Making meat..."
say "...and mixing it all up" if args['--mix']
puts "Making meat..."
puts "...and mixing it all up" if args['--mix']
end

# return back to global namespace
command

action :eat do
say "Custard? Good! Jam? Good! Meat? Good!!!"
puts "Custard? Good! Jam? Good! Meat? Good!!!"
end
6 changes: 3 additions & 3 deletions examples/g_overloading/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# this is a globel action
action :jump do
say "Jump!"
puts "Jump!"
end

# define a namespace with the same name as the global action
Expand All @@ -11,12 +11,12 @@ command "jump"
# this will be "jump around"
usage "around"
action :around do
say "Jump around"
puts "Jump around"
end

# this will be "jump up"
usage "up"
action :up do
say "Jump up jump up and get down"
puts "Jump up jump up and get down"
end

6 changes: 3 additions & 3 deletions examples/h_hyphen/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option "-u --up" , "Also jump up"
option "-d --down", "Get down after jump"

action :'jump-around' do |args|
say "Jump around"
say "Jump up jump up" if args['--up']
say "and get down" if args['--down']
puts "Jump around"
puts "Jump up jump up" if args['--up']
puts "and get down" if args['--down']
end
8 changes: 4 additions & 4 deletions examples/i_crosscall/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# run it from the command prompt.

action :jog do
say "jog"
puts "jog"
end

usage "jump [--high --twice]"
action :jump do |args|
word = args['--high'] ? "JUMP" : "jump"
say word
say word if args['--twice']
puts word
puts word if args['--twice']
end

# this action calls other actions, including one in a different
Expand All @@ -24,7 +24,7 @@ end
command "eat"

action :cake do
say "time for cake"
puts "time for cake"
end

action :'two-cakes' do
Expand Down
8 changes: 4 additions & 4 deletions examples/j_customname/greet.runfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@

usage "hello [<name>]"
action :hello do |args|
say "hello #{args['<name>']}"
puts "hello #{args['<name>']}"
end

command "spanish"

usage "hello [<name>]"
action :hello do |args|
say "hola #{args['<name>']}"
puts "hola #{args['<name>']}"
end

command "french"

usage "hello [<name>]"
action :hello do |args|
say "bonjour #{args['<name>']}"
puts "bonjour #{args['<name>']}"
end

command

action :bye do
say "bye"
puts "bye"
end
4 changes: 2 additions & 2 deletions examples/k_endcommand/Runfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
command "drink"

action :beer do
say "drink beer"
puts "drink beer"
end

# this is an alias to 'command', you can use either an empty call to
# 'command' or 'endcommand' to go back to the global namespace
endcommand

action :eat do
say "eat"
puts "eat"
end
12 changes: 6 additions & 6 deletions examples/l_compact_usage/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

usage "(wakeup|code|sleep)"
action :wakeup do
say "wakeup"
puts "wakeup"
end

usage false
action :code do
say "code"
puts "code"
end

usage false
action :sleep do
say "sleep"
puts "sleep"
end

# this works exactly the same for a namespaced command
Expand All @@ -25,16 +25,16 @@ command "weekend"

usage "(wakeup|play|sleep)"
action :wakeup do
say "wakeup early"
puts "wakeup early"
end

usage false
action :play do
say "play"
puts "play"
end

usage false
action :sleep do
say "sleep late"
puts "sleep late"
end

4 changes: 2 additions & 2 deletions examples/m_dynamic_actions/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ actions = [:css, :js, :'a-movie', :'friends-again']
actions.each do |act|
help "Watch files of type #{act}"
action act do
say act.to_s
puts act.to_s
end
end

Expand All @@ -27,6 +27,6 @@ actions.each do |act|
usage usage_text
usage_text = false
action act do
say "git #{act}"
puts "git #{act}"
end
end
4 changes: 4 additions & 0 deletions examples/n_global_action/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# 1. the executed command matches the usage pattern
# 2. AND it does not match any other command in the file

# Just so we can 'say' with colors
require 'colsole'
include Colsole

usage "<file> <user> [--color]"
help "This is an action without a command"
option "--color", "Use color"
Expand Down
6 changes: 3 additions & 3 deletions examples/o_options_label/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
usage "copy <file> [--force]"
option "--force", "Overwrite target", "Copy Options"
action :copy do |args|
say "Copying #{args['<file>']}"
puts "Copying #{args['<file>']}"
end

usage "rename <file> [--yes]"
option "--yes", "Rename even if read only", "Rename Options"
action :rename do |args|
say "Renaming #{args['<file>']}"
puts "Renaming #{args['<file>']}"
end

# the option below will be added as usual, to the 'Options:' group

usage "show [--all]"
option "--all", "Show all"
action :all do
say "Showing all"
puts "Showing all"
end
6 changes: 3 additions & 3 deletions examples/p_alias/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# The usage pattern will be generated automatically as
# "(server|s)"
action :server, :s do
say "Running server..."
puts "Running server..."
end

# For cases with other patameters, specify the usage pattern:
usage "(greet|g) <name>"
help "Say hello to <name>"
action :greet, :g do |args|
say "Hello #{args['<name>']}"
puts "Hello #{args['<name>']}"
end

# Start a namespace, to ensure this works in a napespaced form
command "watch"

action :dog, :d do
say "Watch dog"
puts "Watch dog"
end

4 changes: 2 additions & 2 deletions examples/q_example/Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option "--force", "Overwrite target", "Copy Options"
example "copy somefile.txt --force"
example "copy somefile.txt"
action :copy do |args|
say "Copying #{args['<file>']}"
puts "Copying #{args['<file>']}"
end

# Example 2: Namespaced
Expand All @@ -23,7 +23,7 @@ option "--daemon", "Start in the background", "Server options"
example "start"
example "start --daemon"
action :start do |args|
say "Starting server..."
puts "Starting server..."
end

endcommand
Loading

0 comments on commit 06f37bf

Please sign in to comment.