From 22e5dd2e03934128ecef8160e2e6bb1a169d43f0 Mon Sep 17 00:00:00 2001 From: Nimble Date: Sun, 18 Sep 2022 17:36:44 -0500 Subject: [PATCH] semi-squeleton and playing with cli input --- shard.yml | 2 +- src/help.cr | 49 ++++++++++++++++++++++++++++++++++++++++++++ src/hosts/M3U8.cr | 4 ++++ src/hosts/XSPF.cr | 5 +++++ src/hosts/spotify.cr | 4 ++++ src/hosts/youtube.cr | 3 +++ src/metadata.cr | 2 ++ src/playper.cr | 3 +++ src/reader_input.cr | 28 +++++++++++++++++++++++++ src/swapper.cr | 9 ++++++++ 10 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/help.cr create mode 100644 src/hosts/M3U8.cr create mode 100644 src/hosts/XSPF.cr create mode 100644 src/hosts/spotify.cr create mode 100644 src/hosts/youtube.cr create mode 100644 src/metadata.cr create mode 100644 src/reader_input.cr create mode 100644 src/swapper.cr diff --git a/shard.yml b/shard.yml index 758b664..994bad6 100644 --- a/shard.yml +++ b/shard.yml @@ -8,6 +8,6 @@ targets: playper: main: src/playper.cr -crystal: 1.3.2 +crystal: 1.4.0 license: AGPL diff --git a/src/help.cr b/src/help.cr new file mode 100644 index 0000000..7d9d9dd --- /dev/null +++ b/src/help.cr @@ -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 diff --git a/src/hosts/M3U8.cr b/src/hosts/M3U8.cr new file mode 100644 index 0000000..0b08016 --- /dev/null +++ b/src/hosts/M3U8.cr @@ -0,0 +1,4 @@ +# M3U8 +# Input +# swapper.cr +# Output diff --git a/src/hosts/XSPF.cr b/src/hosts/XSPF.cr new file mode 100644 index 0000000..2d56448 --- /dev/null +++ b/src/hosts/XSPF.cr @@ -0,0 +1,5 @@ +# XSPF +# Input +# swapper.cr +# Output +require "xml" diff --git a/src/hosts/spotify.cr b/src/hosts/spotify.cr new file mode 100644 index 0000000..16bd93c --- /dev/null +++ b/src/hosts/spotify.cr @@ -0,0 +1,4 @@ +# Spotify API interactions +# GET +# POST +# Need to read deep into the API and make it the most user friendly possible. diff --git a/src/hosts/youtube.cr b/src/hosts/youtube.cr new file mode 100644 index 0000000..6559172 --- /dev/null +++ b/src/hosts/youtube.cr @@ -0,0 +1,3 @@ +# Youtube API +# Get +# Post diff --git a/src/metadata.cr b/src/metadata.cr new file mode 100644 index 0000000..babdf22 --- /dev/null +++ b/src/metadata.cr @@ -0,0 +1,2 @@ +# API for collecting and connecting to metadata providers as well as parsing that +# And return it for other functions diff --git a/src/playper.cr b/src/playper.cr index 3021ecf..2b0cd20 100644 --- a/src/playper.cr +++ b/src/playper.cr @@ -1,6 +1,9 @@ # TODO: Write documentation for `Playper` +include Reader_Input module Playper VERSION = "0.1.0" # TODO: Put your code here + end + diff --git a/src/reader_input.cr b/src/reader_input.cr new file mode 100644 index 0000000..89a866d --- /dev/null +++ b/src/reader_input.cr @@ -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 diff --git a/src/swapper.cr b/src/swapper.cr new file mode 100644 index 0000000..831cd38 --- /dev/null +++ b/src/swapper.cr @@ -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