Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated code to work with gli 2.x.

  • Loading branch information...
commit 4f82629ce0460737db3a8b24f3e06ba09dec9a7e 1 parent 6807aee
@h3rald authored
View
2  book/compile
@@ -9,4 +9,4 @@ Dir.chdir '../book'
require_relative '../lib/glyph.rb'
require_relative '../lib/glyph/commands.rb'
-GLI.run ["compile", '-f', 'pdf']
+GLI::App.run ["compile", '-f', 'pdf']
View
2  book/compile_web
@@ -9,4 +9,4 @@ Dir.chdir '../book'
require_relative '../lib/glyph.rb'
require_relative '../lib/glyph/commands.rb'
-GLI.run ["-d", "compile", '-f', 'h3rald']
+GLI::App.run ["-d", "compile", '-f', 'h3rald']
View
6 book/text/ref_commands.glyph
@@ -15,9 +15,9 @@ section[
p[If specified, the command is executed in debug mode and additional diagnostic information is printed on the screen.]
]
section[
- @title[code[-v], code[--version]]
- @id[version_switch]
- p[Prints the current version of Glyph, ignoring any other command or switches.]
+ @title[code[-h], code[--help]]
+ @id[help_switch]
+ p[Displays help on the program.]
]
]
section[
View
10 glyph.gemspec
@@ -32,15 +32,15 @@ Gem::Specification.new do |s|
s.default_executable = "glyph"
s.extra_rdoc_files = Dir.glob "*.textile"
- s.add_runtime_dependency("gli", [">= 1.6.0"])
+ s.add_runtime_dependency("gli", [">= 2.4.1"])
s.add_runtime_dependency("extlib", [">= 0.9.15"])
s.add_runtime_dependency("rake", [">= 0.9.2.2"])
- s.add_development_dependency("rspec", [">= 2.9.0"])
- s.add_development_dependency("yard", [">= 0.8.1"])
+ s.add_development_dependency("rspec", [">= 2.11.0"])
+ s.add_development_dependency("yard", [">= 0.8.3"])
s.add_development_dependency("directory_watcher", [">= 1.4.1"])
- s.add_development_dependency("sass", [">= 3.1.16"])
+ s.add_development_dependency("sass", [">= 3.2.1"])
s.add_development_dependency("RedCloth", [">= 4.2.9"])
s.add_development_dependency("bluecloth", [">= 2.2.0"])
- s.add_development_dependency("coderay", [">= 1.0.6"])
+ s.add_development_dependency("coderay", [">= 1.0.8"])
end
View
2  lib/glyph.rb
@@ -278,7 +278,7 @@ def self.compile(src, out=nil)
require 'glyph/commands'
self['system.quiet'] = true
self.library_mode = true
- GLI.run ["compile", src.to_s, out].compact
+ TOPLEVEL_BINDING.eval('self').run ["compile", src.to_s, out].compact
rescue Exception => e
raise
ensure
View
24 lib/glyph/commands.rb
@@ -1,20 +1,16 @@
# encoding: utf-8
-include GLI
+include GLI::App
-GLI.desc "Enable debugging"
+program_desc "A rapid document authoring framework"
+
+d "Enable debugging"
switch [:d, :debug]
-GLI.desc "Prints the version of the program"
-switch [:v, :version]
+d "Display documentation"
+switch [:h, :help]
-require Glyph::LIB/'commands/init'
-require Glyph::LIB/'commands/add'
-require Glyph::LIB/'commands/compile'
-require Glyph::LIB/'commands/config'
-require Glyph::LIB/'commands/todo'
-require Glyph::LIB/'commands/outline'
-require Glyph::LIB/'commands/stats'
+commands_from Glyph::LIB/"commands"
Glyph.run 'load:tasks'
Glyph.run 'load:commands'
@@ -26,11 +22,7 @@
if global[:d] then
Glyph.debug_mode = true
end
- if global[:v] || !command || command.name == :help then
- puts "Glyph v#{Glyph::VERSION}"
- puts
- end
- global[:v] ? false : true
+ true
end
post do |global,command,options,args|
View
2  lib/glyph/commands/add.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Add a new text file to the project'
+d 'Add a new text file to the project'
arg_name "file_name"
command :add do |c|
c.action do |global_options,options,args|
View
2  lib/glyph/commands/compile.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Compile the project'
+d 'Compile the project'
arg_name "[source_file] [destination_file]"
command :compile do |c|
c.desc "Specify a glyph file to compile (default: document.glyph)"
View
2  lib/glyph/commands/config.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Get/set configuration settings'
+d 'Get/set configuration settings'
arg_name "setting [new_value]"
command :config do |c|
c.desc "Read from/Save to global configuration"
View
2  lib/glyph/commands/init.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Create a new Glyph project'
+d 'Create a new Glyph project'
command :init do |c|
c.action do |global_options,options,args|
Glyph.run 'project:create', Dir.pwd
View
2  lib/glyph/commands/outline.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Display the document outline'
+d 'Display the document outline'
command :outline do |c|
c.desc "Limit to level N"
c.flag :l, :level
View
2  lib/glyph/commands/stats.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Display statistics'
+d 'Display statistics'
command :stats do |c|
c.desc "Display stats about macros"
c.switch [:m, :macros]
View
2  lib/glyph/commands/todo.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-GLI.desc 'Display all project TODO items'
+d 'Display all project TODO items'
command :todo do |c|
c.action do |global_options, options, args|
Glyph['system.quiet'] = true
View
11 spec/lib/commands_spec.rb
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# encoding: utf-8
+
require File.join(File.dirname(__FILE__), "..", "spec_helper")
-require 'glyph/commands'
describe "glyph" do
@@ -14,11 +14,6 @@
reset_quiet
delete_project
end
-
- it "[-v] should pront the program name and version and quit" do
- run_command(["-v"]).should == "Glyph v#{Glyph::VERSION}\n\n"
- run_command(["-v", "compile"]).should == "Glyph v#{Glyph::VERSION}\n\n"
- end
it "[init] should create a project in the current directory" do
delete_project
@@ -35,7 +30,7 @@
it "[config] should write configuration settings" do
create_project
- run_command_successfully(["config", "test_setting", true]).should == true
+ run_command_successfully(["config", "test_setting", "true"]).should == true
Glyph::CONFIG.get(:test_setting).should == true
Glyph::PROJECT_CONFIG.read
Glyph::PROJECT_CONFIG.get('test_setting').should == true
@@ -54,7 +49,7 @@
it "[config] should not overwrite system settings" do
create_project
Glyph['system.test_setting'] = false
- run_command(["config", "system.test_setting", true]).match(/warning.+\(system use only\)/m).should_not == nil
+ run_command(["config", "system.test_setting", "true"]).match(/warning.+\(system use only\)/m).should_not == nil
Glyph['system.test_setting'].should == false
end
View
4 spec/spec_helper.rb
@@ -13,6 +13,8 @@ module Glyph; end
end
require "glyph"
+require "glyph/commands"
+
Glyph['system.quiet'] = true
@@ -71,7 +73,7 @@ def delete_project
def run_command(cmd, return_code=false)
result = 0
out = stdout_for do
- result = GLI.run cmd
+ result = TOPLEVEL_BINDING.eval('self').run cmd
end
return_code ? result : out
end
View
5 tasks/load.rake
@@ -19,10 +19,7 @@ namespace :load do
desc "Load commands"
task :commands do
unless Glyph.lite? then
- include GLI if (Glyph::PROJECT/'lib/commands').exist?
- load_files_from_dir(Glyph::PROJECT/'lib/commands', '.rb') do |f, contents|
- require f
- end
+ commands_from Glyph::PROJECT/'lib/commands'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.