Skip to content

Commit

Permalink
Merge pull request #18 from harrisonhoward/feature/#16--clean-up-comm…
Browse files Browse the repository at this point in the history
…and-utils

#16 Clean up the command utils
  • Loading branch information
harrisonhoward authored May 17, 2024
2 parents 8e60aac + f035664 commit 9f008fa
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 47 deletions.
6 changes: 4 additions & 2 deletions src/commands/auth.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import plex_pin_auth
import plex_pin_auth/util/parser.{type PlexError, type PlexPin}
import repeatedly
import util/client_identifier
import util/commands/auth_tool
import util/env.{ConfigOption}
import util/terminal

/// Description for the 'auth' command
pub const description = "Setups the Plex authentication config."

/// The interval in which we poll the server for the token
const interval_ms = 2000

Expand Down Expand Up @@ -110,7 +112,7 @@ pub fn command(to glint: Glint(Nil)) {
to: glint,
at: ["auth"],
do: glint.command(do)
|> glint.description(auth_tool.description),
|> glint.description(description),
)
}

Expand Down
6 changes: 4 additions & 2 deletions src/commands/config.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import gleam/io
import gleam/option.{None, Some}
import gleam/string
import glint.{type CommandInput, type Glint}
import util/commands/watch_tool
import util/env.{ConfigOption}
import util/terminal

/// Description for the 'config' command
pub const description = "Write the config file for the your specific environment."

/// The 'config' command logic
fn do(_input: CommandInput) {
// Basic information for user to understand what's going on
Expand Down Expand Up @@ -121,6 +123,6 @@ pub fn command(to glint: Glint(Nil)) {
to: glint,
at: ["config"],
do: glint.command(do)
|> glint.description(watch_tool.description),
|> glint.description(description),
)
}
27 changes: 24 additions & 3 deletions src/commands/help.gleam
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
//// Command logic for the help command. This is the base help command when entering an unknown command.

import commands/auth.{description as auth_description}
import commands/config.{description as config_description}
import commands/watch.{description as watch_description}
import gleam/io
import glint.{type CommandInput, type Glint}
import util/commands/help_tool

/// Description for the 'help' command
const description = "Below are the commands that are available in this project.\nIf you need help with a specific command attach the flag '--help' when running the command."

/// Runs the print function for the 'help' command
fn do(_input: CommandInput) {
help_tool.print()
io.println(
description
<> "\n\n"
<> "USAGE:\n"
<> "\tplexrpc [ ARGS ]"
<> "\n\n"
<> "SUBCOMMANDS:\n"
<> "\twatch\t\t"
<> watch_description
<> "\n"
<> "\tauth\t\t"
<> auth_description
<> "\n"
<> "\tconfig\t\t"
<> config_description,
)
}

/// Adds the 'help' command to the glint instance.
Expand All @@ -14,6 +35,6 @@ pub fn command(to glint: Glint(Nil)) {
to: glint,
at: [],
do: glint.command(do)
|> glint.description(help_tool.description),
|> glint.description(description),
)
}
6 changes: 4 additions & 2 deletions src/commands/watch.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import gleam/io
import glint.{type CommandInput, type Glint}
import util/commands/watch_tool

/// Description for the 'watch' command
pub const description = "Initiate the Plex RPC. Requires Plex auth and Discord to be open."

/// The 'watch' command logic
fn do(_input: CommandInput) {
Expand All @@ -15,6 +17,6 @@ pub fn command(to glint: Glint(Nil)) {
to: glint,
at: ["watch"],
do: glint.command(do)
|> glint.description(watch_tool.description),
|> glint.description(description),
)
}
2 changes: 0 additions & 2 deletions src/util/commands/auth_tool.gleam

This file was deleted.

2 changes: 0 additions & 2 deletions src/util/commands/config_tool.gleam

This file was deleted.

32 changes: 0 additions & 32 deletions src/util/commands/help_tool.gleam

This file was deleted.

2 changes: 0 additions & 2 deletions src/util/commands/watch_tool.gleam

This file was deleted.

0 comments on commit 9f008fa

Please sign in to comment.