Sha256: c5e37174cc5ffd2dfbc253c2fccf58af9979e0345da72e4891bb2ae798bacc9e

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

#!/usr/bin/env ruby

require 'rubypitaya'

COMMANDS = ['run', 'create', 'create-migration', 'add-plugin']

def main
  if ARGV.size == 0 || !COMMANDS.include?(ARGV[0])
    show_help()
    exit(-1)
  end

  command = ARGV[0]

  if command == 'run'
    command_run(ARGV)
  end

  if command == 'create'
    command_create(ARGV)
  end

  if command == 'create-migration'
    command_create_migration(ARGV)
  end

  if command == 'add-plugin'
    command_add_plugin(ARGV)
  end
end

def command_run(argv)
  puts 'Starting server...'
  RubyPitaya::RubyPitaya.run_server
end

def command_create(argv)
  if argv.size <= 1
    show_help_create()
    exit(-1)
  end

  project_name = argv[1]
  folder_path = Dir.pwd

  RubyPitaya::RubyPitaya.create_project(project_name, folder_path)

  puts "Project #{project_name} created!"
end

def command_create_migration(argv)
  if argv.size <= 1
    show_help_create_migration()
    exit(-1)
  end

  migration_name = argv[1]

  migration_file_name = RubyPitaya::RubyPitaya.create_migration(migration_name)

  puts "Migration #{migration_file_name} created!"
end

def command_add_plugin(argv)
  if argv.size <= 1
    show_help_add_plugin()
    exit(-1)
  end

  plugin_git_link = argv[1]

  plugin_name = RubyPitaya::RubyPitaya.add_plugin(plugin_git_link)

  puts "Plugin #{plugin_name} added!"
end

def show_help
  puts 'Usage: $ rubypitaya [COMMAND]'
  puts 'COMMAND:'
  puts '  run:              - Run server'
  puts '  create:           - Create project'
  puts '  create-migration: - Create migration'
  puts ''
end

def show_help_create
  puts 'Usage: $ rubypitaya create [project_name]'
  puts ''
end

def show_help_create_migration
  puts 'Usage: $ rubypitaya create-migration [migration_name]'
  puts ''
end

def show_help_add_plugin
  puts 'Usage: $ rubypitaya add-plugin [plugin_git_link]'
  puts ''
end

main

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubypitaya-2.23.0 bin/rubypitaya
rubypitaya-2.22.0 bin/rubypitaya
rubypitaya-2.21.0 bin/rubypitaya
rubypitaya-2.20.0 bin/rubypitaya
rubypitaya-2.19.1 bin/rubypitaya
rubypitaya-2.19.0 bin/rubypitaya
rubypitaya-2.18.0 bin/rubypitaya
rubypitaya-2.17.0 bin/rubypitaya
rubypitaya-2.16.0 bin/rubypitaya
rubypitaya-2.15.0 bin/rubypitaya
rubypitaya-2.14.1 bin/rubypitaya
rubypitaya-2.14.0 bin/rubypitaya