Skip to content

Conversation

@ChausseBenjamin
Copy link
Contributor

@ChausseBenjamin ChausseBenjamin commented Jul 22, 2025

Urfave cli is greate for parsing flags since it does many things in one which are closely related:

  • argument validation (ensures a path is valid or a resolution matches an <int>p such as 720p)
  • multiple sources for arguments: long/short flags (--downloads-path/-d), environment variables and toml config files (and other formats if desired)
  • flag/config documentation
  • flag/config priority (directly calling a flag like --downloads-path takes precedence over what's defined in gophertube.toml

I made a new GOPHERTUBE_CONFIG environment variable that lets users put their toml config wherever they want in case they don't like the default.

Also, it pre-packages the -v/--version and -h,--help flags for you so you don't have to update them as your flags/versions evolve.

What some flags now look like

$ gophertube --help
NAME:
   GopherTube - Terminal YouTube Search & Play

USAGE:
   GopherTube [global options]

VERSION:
   dev

DESCRIPTION:
   Gophertube is a terminal-based YouTube search and video player application.
   Navigate through YouTube content efficiently using keyboard shortcuts and enjoy
   seamless video playback directly from your terminal.

   Controls:
     • Type your search query and press Enter
     • Use ↑/↓ to navigate results
     • Press Tab to load more results
     • Press Esc to go back or exit


AUTHOR:
   KrishnaSSH <krishna.pytech@gmail.com>

GLOBAL OPTIONS:
   --config string, -c string          (default: $HOME/.config/gophertube/gophertube.toml) [$GOPHERTUBE_CONFIG]
   --downloads-path string, -d string  (default: $HOME/Videos/GopherTube)
   --search-limit int, -l int          (default: 30)
   --quality string, -q string         (default: "720p")
   --help, -h                          show help
   --version, -v                       print the version
$ gophertube -v
GopherTube version dev

You'd no longer have the ANSI colors with those flags, but the new general structure would be quite robust.

@ChausseBenjamin ChausseBenjamin marked this pull request as ready for review July 22, 2025 15:09
@KrishnaSSH
Copy link
Owner

Thanks for the PR! ❤️

@KrishnaSSH KrishnaSSH merged commit f979871 into KrishnaSSH:main Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants