Sha256: 646275c00a36bc15faaa6cb4340f21385ad6e62d32c358a7468d32b771d62648

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

#!/usr/bin/env ruby

# $LOAD_PATH << "./lib"

require 'runeblog'
require 'rubytext'

require 'repl'

include RuneBlog::REPL

def mainloop
  print fx("blog> ", Red, :bold)
  cmd = STDSCR.gets(history: @cmdhist, tab: @tabcom)
  cmd_quit(nil) if cmd.nil?   # ^D
  cmd.chomp!
  return if cmd.empty?   # CR does nothing
  meth, params = RuneBlog::REPL.choose_method(cmd)
  ret, str = send(meth, params)
rescue => err
  puts err
end

###

major, minor = RUBY_VERSION.split(".").values_at(0,1)
ver = major.to_i*10 + minor.to_i
abort "Need Ruby 2.4 or greater" unless ver >= 24

include RuneBlog::Helpers  # for try_read_config

# read a .rubytext file here??
home = ENV['HOME']
@fg, @bg = try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
@fg = @fg.downcase.to_sym
@bg = @bg.downcase.to_sym

RubyText.start(:_echo, :keypad, scroll: true, log: "blogcmd.txt", fg: @fg, bg: @bg)

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

@blog = RuneBlog.new

puts fx("\n  RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)
@cmdhist = []
@tabcom = RuneBlog::REPL::Patterns.keys
@tabcom.map! {|x| x.sub(/ \$.*/, " ") }
loop { mainloop }
sleep 0.2
system("tput clear")
puts

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
runeblog-0.1.48 bin/blog
runeblog-0.1.47 bin/blog