Class: Softcover::CLI
- Inherits:
-
Thor
- Object
- Thor
- Softcover::CLI
show all
- Includes:
- Utils
- Defined in:
- lib/softcover/cli.rb
Constant Summary
Constants included
from Utils
Utils::UNITS
Instance Method Summary
collapse
Methods included from Utils
#add_highlight_class!, #article?, #as_size, #book_file_lines, #chapter_label, #commands, #current_book, #dependency_filename, #digest, #executable, #execute, #filename_or_default, #get_filename, #in_book_directory?, #language_labels, #linux?, #logged_in?, #master_content, #master_filename, #master_latex_header, #mkdir, #non_comment_lines, #os_x?, #path, #raw_lines, #reset_current_book!, #rm, #rm_r, #silence, #source, #template_dir, #tmpify, #unpublish_slug, #write_master_latex_file, #write_pygments_file
Instance Method Details
#clean ⇒ Object
77
78
79
80
81
82
83
84
85
|
# File 'lib/softcover/cli.rb', line 77
def clean
rm(Dir.glob('*.aux'))
rm(Dir.glob(File.join('chapters', '*.aux')))
rm(Dir.glob('*.toc'))
rm(Dir.glob('*.out'))
rm(Dir.glob('*.tmp.*'))
rm(Dir.glob(path('tmp/*')))
rm('.highlight_cache')
end
|
#login ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/softcover/cli.rb', line 115
def login
puts "Logging in."
logged_in = false
while not logged_in do
email = ask "Email:"
password = ask_without_echo "Password (won't be shown):"
unless logged_in = Softcover::Commands::Auth.login(email, password)
puts "Invalid login, please try again."
end
end
puts "Welcome back, #{email}!"
end
|
#publish ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'lib/softcover/cli.rb', line 145
def publish
require 'softcover/commands/publisher'
invoke :login unless logged_in?
puts "Publishing..." unless options[:silent]
Softcover::Commands::Publisher.publish!(options)
end
|
#unpublish ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/softcover/cli.rb', line 178
def unpublish
require 'softcover/commands/publisher'
invoke :login unless logged_in?
slug = options[:slug] || unpublish_slug
if options[:force] || ask("Type '#{slug}' to unpublish:") == slug
puts "Unpublishing..." unless options[:silent]
Softcover::Commands::Publisher.unpublish!(slug)
else
puts "Canceled."
end
end
|
#version ⇒ Object
12
13
14
15
16
|
# File 'lib/softcover/cli.rb', line 12
def version
require 'softcover/version'
puts "Softcover #{Softcover::VERSION}"
exit 0
end
|