yanky testing + correct use of include+extend
This commit is contained in:
parent
93ac7be198
commit
b1950d4610
2 changed files with 64 additions and 44 deletions
|
@ -4,15 +4,33 @@
|
|||
# This is designed to initialize everything
|
||||
# Reference for modules https://crystal-lang.org/reference/1.7/syntax_and_semantics/modules.html
|
||||
|
||||
# Commenting working code (u need to use flags if it doesn't work)
|
||||
# require "./tryerror/*"
|
||||
# require "./reader_input.cr"
|
||||
#
|
||||
# module Playper
|
||||
# include ReaderInput
|
||||
# include HelpTest
|
||||
#
|
||||
# VERSION = "0.1.0"
|
||||
#
|
||||
# # TODO: Put your code here
|
||||
# puts "Hello world!"
|
||||
# #ReaderInput.cli_input #runs cli_input from ReaderInput
|
||||
# HelpTest
|
||||
# end
|
||||
|
||||
require "./tryerror/*"
|
||||
require "./reader_input.cr"
|
||||
|
||||
module Playper
|
||||
include ReaderInput
|
||||
include HelpTest
|
||||
|
||||
VERSION = "0.1.0"
|
||||
|
||||
# TODO: Put your code here
|
||||
print("Hello world!")
|
||||
ReaderInput.cli_input #runs cli_input from ReaderInput
|
||||
puts "Hello world!"
|
||||
#ReaderInput.cli_input #runs cli_input from ReaderInput
|
||||
HelpTest
|
||||
end
|
||||
|
|
|
@ -2,50 +2,52 @@
|
|||
|
||||
require "option_parser"
|
||||
require "colorize"
|
||||
module HelpTest
|
||||
extend self
|
||||
the_beatles = [
|
||||
"John Lennon",
|
||||
"Paul McCartney",
|
||||
"George Harrison",
|
||||
"Ringo Starr",
|
||||
]
|
||||
|
||||
the_beatles = [
|
||||
"John Lennon",
|
||||
"Paul McCartney",
|
||||
"George Harrison",
|
||||
"Ringo Starr",
|
||||
]
|
||||
say_hi_to = ""
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "These are the options for playper-cli: "
|
||||
#parser.banner = "#{"The Beatles"App"
|
||||
|
||||
say_hi_to = ""
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "These are the options for playper-cli: "
|
||||
#parser.banner = "#{"The Beatles"App"
|
||||
parser.on "-v", "--version", "Show version" do
|
||||
puts "version 0.1.0"
|
||||
exit
|
||||
end
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts parser
|
||||
exit
|
||||
end
|
||||
parser.on "-sp", "--spotify", "Show version" do
|
||||
puts "Make use of spotify info."
|
||||
exit
|
||||
end
|
||||
parser.on "-g NAME", "--goodbye_hello=NAME", "Say hello to whoever you want" do |name|
|
||||
say_hi_to = name
|
||||
end
|
||||
# Exception Handling
|
||||
parser.missing_option do |option_flag|
|
||||
STDERR.puts "ERROR: #{option_flag} is missing something.".colorize(:green).on(:black)
|
||||
STDERR.puts ""
|
||||
STDERR.puts parser
|
||||
exit(1)
|
||||
end
|
||||
parser.invalid_option do |option_flag|
|
||||
STDERR.puts "ERROR: #{option_flag} is not a valid option.".colorize(:yellow).on(:black)
|
||||
STDERR.puts parser
|
||||
exit(1)
|
||||
end
|
||||
#puts parser
|
||||
end
|
||||
|
||||
parser.on "-v", "--version", "Show version" do
|
||||
puts "version 0.1.0"
|
||||
exit
|
||||
unless say_hi_to.empty?
|
||||
puts ""
|
||||
puts "You say goodbye, and #{the_beatles.sample} says hello to #{say_hi_to}!"
|
||||
end
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts parser
|
||||
exit
|
||||
end
|
||||
parser.on "-sp", "--spotify", "Show version" do
|
||||
puts "Make use of spotify info."
|
||||
exit
|
||||
end
|
||||
parser.on "-g NAME", "--goodbye_hello=NAME", "Say hello to whoever you want" do |name|
|
||||
say_hi_to = name
|
||||
end
|
||||
# Exception Handling
|
||||
parser.missing_option do |option_flag|
|
||||
STDERR.puts "ERROR: #{option_flag} is missing something.".colorize(:green).on(:black)
|
||||
STDERR.puts ""
|
||||
STDERR.puts parser
|
||||
exit(1)
|
||||
end
|
||||
parser.invalid_option do |option_flag|
|
||||
STDERR.puts "ERROR: #{option_flag} is not a valid option.".colorize(:yellow).on(:black)
|
||||
STDERR.puts parser
|
||||
exit(1)
|
||||
end
|
||||
#puts parser
|
||||
end
|
||||
|
||||
unless say_hi_to.empty?
|
||||
puts ""
|
||||
puts "You say goodbye, and #{the_beatles.sample} says hello to #{say_hi_to}!"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue