Sha256: 0e1b88a5edd6174fff1c465f08d85b6560ff4a8d88eb7cf8c80f1ff71c70e58a
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
#!/usr/bin/env ruby # $LOAD_PATH << "./lib" require 'global' require 'rubytext' if curses? require 'readline' require 'repl' # trap("INT") { } include RuneBlog::REPL def get_argv return nil if ARGV.size == 0 cmd = ARGV[0..1].join(" ") arg = ARGV[2] [cmd, arg] end ########### STDOUT.sync = true cmd, arg = get_argv if ! RuneBlog.exist? print "No blog found. Create new one? (y/n) " resp = gets.chomp if resp == "y" RuneBlog.create_new_blog else exit end end def mainloop if curses? print red("blog> ") cmd = gets else cmd = Readline.readline(red("\nblog> "), true) end cmd_quit(nil) if cmd.nil? # ^D cmd.chomp! return if cmd.empty? # CR does nothing meth, params = RuneBlog::REPL.choose_method(cmd) str = send(meth, params) puts str unless str.nil? rescue => err puts err end puts curses? sleep 6 if curses? RubyText.start(:echo, :noraw, log: "debug.out") end @blog = RuneBlog.new if cmd.nil? # REPL system("tput smcup") # see: tput rmcup in cmd_quit puts red("\n RuneBlog v #{RuneBlog::VERSION}") loop { mainloop } else # one command file = File.open("/dev/tty") STDIN.reopen(file) # avoid ARGF dumbness cmd = ARGV.join(" ") meth, params = RuneBlog::REPL.choose_method(cmd) str = send(meth, params) puts str unless str.nil? puts end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
runeblog-0.1.2 | bin/blog |