Skip to content
This repository
Browse code

Updated code to work with gli 2.x.

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

0 notes on commit 4f82629

Please sign in to comment.
Something went wrong with that request. Please try again.