semi-squeleton and playing with cli input

This commit is contained in:
Nimble 2022-09-18 17:36:44 -05:00
parent c119ef7b4d
commit 22e5dd2e03
10 changed files with 108 additions and 1 deletions

View File

@ -8,6 +8,6 @@ targets:
playper:
main: src/playper.cr
crystal: 1.3.2
crystal: 1.4.0
license: AGPL

49
src/help.cr Normal file
View File

@ -0,0 +1,49 @@
require "option_parser"
require "colorize"
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"
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
unless say_hi_to.empty?
puts ""
puts "You say goodbye, and #{the_beatles.sample} says hello to #{say_hi_to}!"
end

4
src/hosts/M3U8.cr Normal file
View File

@ -0,0 +1,4 @@
# M3U8
# Input
# swapper.cr
# Output

5
src/hosts/XSPF.cr Normal file
View File

@ -0,0 +1,5 @@
# XSPF
# Input
# swapper.cr
# Output
require "xml"

4
src/hosts/spotify.cr Normal file
View File

@ -0,0 +1,4 @@
# Spotify API interactions
# GET
# POST
# Need to read deep into the API and make it the most user friendly possible.

3
src/hosts/youtube.cr Normal file
View File

@ -0,0 +1,3 @@
# Youtube API
# Get
# Post

2
src/metadata.cr Normal file
View File

@ -0,0 +1,2 @@
# API for collecting and connecting to metadata providers as well as parsing that
# And return it for other functions

View File

@ -1,6 +1,9 @@
# TODO: Write documentation for `Playper`
include Reader_Input
module Playper
VERSION = "0.1.0"
# TODO: Put your code here
end

28
src/reader_input.cr Normal file
View File

@ -0,0 +1,28 @@
require "colorize"
# This is a bit of a metaclass for now
# Its going to be abstract class for input also working with cases
# Middleware between each host and html template
# Directware if used as CLI tool
# Should read
module Reader_Input
def cli_input
#switch()
puts "Welcome to The Beatles Sing-Along version 1.0!"
puts "Enter a phrase you want The Beatles to sing"
print "> "
user_input = gets
exit if user_input.nil? # Ctrl+D
default_lyrics = "Na, na, na, na-na-na na" \
" / " \
"Na-na-na na, hey Jude"
lyrics = user_input.presence || default_lyrics
#puts "The Beatles are singing: #{"🎵#{lyrics}🎶🎸🥁".colorize.mode(:blink)}"
end
end

9
src/swapper.cr Normal file
View File

@ -0,0 +1,9 @@
# Actual swaping of playlist from one format to another
# Different cases for different hosts
# Make use of the metadata class for concurrency
class Swapper
extend Reader_Input
reader = Reader_Input.cli_input
puts "The Beatles are singing: #{"🎵#{reader.lyrics}🎶🎸🥁".colorize.mode(:blink)}"
end