Skip to content

Commit

Permalink
Output format is now specified using the -f option.
Browse files Browse the repository at this point in the history
  • Loading branch information
h3rald committed Feb 22, 2010
1 parent ded84ba commit 49dc0c1
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.textile
Expand Up @@ -29,8 +29,8 @@ Glyph is 100% command line. Its interface "Git's":http://git-scm.com/ for its si

* @glyph init@ -- to initialize a new Glyph project in the current (empty) directory.
* @glyph add introduction.textile@ -- to create a new file called _introduction.textile_.
* @glyph compile html@ -- to compile the current document into a single HTML file.
* @glyph compile pdf@ -- to compile the current document into HTML and then transform it into PDF using =>[http://www.princexml.com|Prince].
* @glyph compile@ -- to compile the current document into a single HTML file.
* @glyph compile -f pdf@ -- to compile the current document into HTML and then transform it into PDF using =>[http://www.princexml.com|Prince].

h3. Glyph macros in a nutshell

Expand Down
4 changes: 2 additions & 2 deletions book/output/html/glyph.html
Expand Up @@ -513,8 +513,8 @@ <h3 id="h_4">Essential Glyph commands</h3>
<ul>
<li><code>glyph init</code> &#8212; to initialize a new Glyph project in the current (empty) directory.</li>
<li><code>glyph add introduction.textile</code> &#8212; to create a new file called <em>introduction.textile</em>.</li>
<li><code>glyph compile html</code> &#8212; to compile the current document into a single <span class="caps">HTML</span> file.</li>
<li><code>glyph compile pdf</code> &#8212; to compile the current document into <span class="caps">HTML</span> and then transform it into <span class="caps">PDF</span> using <a href="http://www.princexml.com">Prince</a>.</li>
<li><code>glyph compile</code> &#8212; to compile the current document into a single <span class="caps">HTML</span> file.</li>
<li><code>glyph compile -f pdf</code> &#8212; to compile the current document into <span class="caps">HTML</span> and then transform it into <span class="caps">PDF</span> using <a href="http://www.princexml.com">Prince</a>.</li>
</ul>
</div>
<div class="section">
Expand Down
Binary file modified book/output/pdf/glyph.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions book/text/introduction.textile
Expand Up @@ -32,8 +32,8 @@ Glyph is 100% command line. Its interface resambles =>[http://git-scm.com/|Git's

* @glyph init@ -- to initialize a new Glyph project in the current (empty) directory.
* @glyph add introduction.textile@ -- to create a new file called _introduction.textile_.
* @glyph compile html@ -- to compile the current document into a single HTML file.
* @glyph compile pdf@ -- to compile the current document into HTML and then transform it into PDF using =>[http://www.princexml.com|Prince].
* @glyph compile@ -- to compile the current document into a single HTML file.
* @glyph compile -f pdf@ -- to compile the current document into HTML and then transform it into PDF using =>[http://www.princexml.com|Prince].

]

Expand Down
2 changes: 2 additions & 0 deletions glyph.gemspec
Expand Up @@ -24,8 +24,10 @@ Gem::Specification.new do |s|
"bin/glyph",
"book/config.yml",
"book/document.glyph",
"book/images/glyph.png",
"book/images/glyph.svg",
"book/output/html/glyph.html",
"book/output/html/images/glyph.png",
"book/output/html/images/glyph.svg",
"book/output/pdf/glyph.pdf",
"book/snippets.yml",
Expand Down
21 changes: 9 additions & 12 deletions lib/glyph/commands.rb
Expand Up @@ -25,19 +25,16 @@
command :compile do |c|
c.desc "Specify a glyph file to compile (default: document.glyph)"
c.flag [:s, :source]
c.desc "Specify the format of the output file (default: html)"
c.flag [:f, :format]
c.action do |global_options, options, args|
Glyph.run 'load:config'
output_targets = Glyph::CONFIG.get('document.output_targets')
target = nil
case args.length
when 0 then
target = cfg('document.output')
target = nil if target.blank?
target ||= cfg('filters.target')
when 1 then
target = args[0]
else
raise ArgumentError, "Too many arguments."
end
Glyph.config_override('document.output', options[:f]) if options[:f]
target = cfg('document.output')
target = nil if target.blank?
target ||= cfg('filters.target')
Glyph.config_override('document.source', options[:s]) if options[:s]
raise ArgumentError, "Output target not specified" unless target
raise ArgumentError, "Unknown output target '#{target}'" unless output_targets.include? target.to_sym
Expand Down Expand Up @@ -114,8 +111,8 @@
false
else
if Glyph.const_defined? :DEBUG then
puts "error: #{exception.message}"
puts "backtrace:"
puts "Exception: #{exception.message}"
puts "Backtrace:"
exception.backtrace.each do |b|
puts b
end
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/commands_spec.rb
Expand Up @@ -46,7 +46,6 @@

it "[compile] should compile the project" do
create_project
run_command_successfully(["compile", "wrong"]).should == false
run_command(["compile"]).match(/test_project\.html/m).should_not == nil
(Glyph::PROJECT/'output/html/test_project.html').exist?.should == true
end
Expand Down Expand Up @@ -76,4 +75,9 @@
res.match(/Snippet 'invalid3' does not exist/).should_not == nil
end

it "[compile] should not compile the project in case of an unknown output format" do
run_command_successfully(["compile", "-f", "wrong"]).should == false
end


end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -56,7 +56,7 @@ def run_command(cmd)
$stdout = out
$stderr = out
Glyph.config_override :quiet, false
GLI.run(cmd)
GLI.run cmd
Glyph.config_override :quiet, true
$stdout = old_stdout
$stderr = old_stderr
Expand Down
2 changes: 1 addition & 1 deletion spec/tasks/load_spec.rb
Expand Up @@ -13,7 +13,7 @@

it "should raise an error unless PROJECT is a valid project directory" do
delete_project
lambda {Glyph.run! 'load:all' }.should raise_error
lambda { Glyph.run! 'load:all' }.should raise_error
end

it "[snippets] should load snippet definitions" do
Expand Down

0 comments on commit 49dc0c1

Please sign in to comment.