class Mailbot::Commands::Sync

Constants

DEFAULT_ENV_FILE
DEFAULT_MARKDOWN_FILE

Public Class Methods

new(argv) click to toggle source

@param argv [Array] ARGV

# File lib/mailbot/commands/sync.rb, line 9
def initialize(argv)
  @argv = argv
end

Public Instance Methods

execute() click to toggle source

Sync the specified file to Mailbox

# File lib/mailbot/commands/sync.rb, line 14
def execute
  load_env!
  Mailbot::Repository.new(file).sync
end

Private Instance Methods

env() click to toggle source
# File lib/mailbot/commands/sync.rb, line 29
def env
  options[:env] || DEFAULT_ENV_FILE
end
file() click to toggle source
# File lib/mailbot/commands/sync.rb, line 25
def file
  options[:file] || DEFAULT_MARKDOWN_FILE
end
load_env!() click to toggle source
# File lib/mailbot/commands/sync.rb, line 21
def load_env!
  Dotenv.load! env
end
options() click to toggle source
# File lib/mailbot/commands/sync.rb, line 33
def options
  @options ||= Slop.parse!(@argv, help: true) do
    banner "Usage: #{$0} sync [options]"
    on "file=", "Path to the markdown file to sync"
    on "env=", "Path to the env file to sync"
  end
end