class Softcover::CLI
Public Instance Methods
build()
click to toggle source
# File lib/softcover/cli.rb, line 27 def build Softcover::Commands::Build.all_formats(options) end
check()
click to toggle source
# File lib/softcover/cli.rb, line 91 def check Softcover::Commands::Check.check_dependencies! end
clean()
click to toggle source
# File lib/softcover/cli.rb, line 76 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') rm('tmp/.highlight_cache') end
config()
click to toggle source
# File lib/softcover/cli.rb, line 243 def config require "softcover/config" puts "Reading contents of #{Softcover::Config.path}:" Softcover::Config.read end
deploy()
click to toggle source
# File lib/softcover/cli.rb, line 196 def deploy Softcover::Commands::Deployment.deploy! end
login()
click to toggle source
# File lib/softcover/cli.rb, line 116 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
logout()
click to toggle source
# File lib/softcover/cli.rb, line 131 def logout Softcover::Commands::Auth.logout end
new(n)
click to toggle source
# File lib/softcover/cli.rb, line 215 def new(n) Softcover::Commands::Generator.generate_file_tree(n, options) end
open()
click to toggle source
# File lib/softcover/cli.rb, line 224 def open Softcover::Commands::Opener.open! end
publish()
click to toggle source
# File lib/softcover/cli.rb, line 146 def publish require 'softcover/commands/publisher' invoke :login unless logged_in? puts "Publishing..." unless options[:silent] Softcover::Commands::Publisher.publish!(options) end
server()
click to toggle source
# File lib/softcover/cli.rb, line 102 def server if Softcover::BookManifest::valid_directory? Softcover::Commands::Server.run options[:port], options[:bind] else puts 'Not in a valid book directory.' exit 1 end end
unpublish()
click to toggle source
# File lib/softcover/cli.rb, line 179 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()
click to toggle source
# File lib/softcover/cli.rb, line 12 def version require 'softcover/version' puts "Softcover #{Softcover::VERSION}" exit 0 end
Protected Instance Methods
ask_without_echo(*args)
click to toggle source
# File lib/softcover/cli.rb, line 276 def ask_without_echo(*args) system "stty -echo" ret = ask *args system "stty echo" puts ret end