Sha256: 5083c52c83e1e7430728d59260a642909db275a9ec2963986ef714b11d0b8d91

Contents?: true

Size: 1.81 KB

Versions: 48

Compression:

Stored size: 1.81 KB

Contents

#!/usr/bin/env ruby

# $LOAD_PATH << "./lib"

require 'runeblog'
require 'rubytext'

require 'repl'

include RuneBlog::REPL

errfile = File.new("stderr.out", "w")
STDERR.reopen(errfile)

def get_started
  puts
  puts fx(<<-TEXT, :bold)
  Blog repo successfully created.
  You can create views with the command: new view
  Create a post within the current view: new post
  You can't publish until you set up the publish file 
    via the config command.
TEXT
end

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?? Call it something else?
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: "binblog.txt", fg: @fg, bg: @bg)

if ! RuneBlog.exist?
  print fx("\n  No blog repo found. Create new one? (y/n): ", :bold)
  response = gets.chomp
  if response.downcase == "y"
    print fx("\n Enter default view name: ", :bold)
    view_name = gets.chomp
    RuneBlog.create_new_blog_repo(view_name)
    get_started
  else
    exit
  end
end

@blog = RuneBlog.new

puts fx("\n  RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)

@cmdhist = []
@tabcom = RuneBlog::REPL::Patterns.keys.uniq - RuneBlog::REPL::Abbr.keys
@tabcom.map! {|x| x.sub(/ [\$\>].*/, "") + " " }
@tabcom.sort!
  
loop { mainloop }

# sleep 0.2
# system("tput clear")
puts

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
runeblog-0.2.33 bin/blog
runeblog-0.2.32 bin/blog
runeblog-0.2.31 bin/blog
runeblog-0.2.30 bin/blog
runeblog-0.2.29 bin/blog
runeblog-0.2.28 bin/blog
runeblog-0.2.27 bin/blog
runeblog-0.2.26 bin/blog
runeblog-0.2.25 bin/blog
runeblog-0.2.24 bin/blog
runeblog-0.2.23 bin/blog
runeblog-0.2.22 bin/blog
runeblog-0.2.18 bin/blog
runeblog-0.2.17 bin/blog
runeblog-0.2.16 bin/blog
runeblog-0.2.15 bin/blog
runeblog-0.2.14 bin/blog
runeblog-0.2.12 bin/blog
runeblog-0.2.11 bin/blog
runeblog-0.2.10 bin/blog