[PR #14813] [CLOSED] replace command line parser with system one #14128

Closed
opened 2026-02-07 07:24:52 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/14813
Author: @ibizaman
Created: 9/17/2025
Status: Closed

Base: masterHead: cli_parser


📝 Commits (1)

  • d1d5335 replace command line parser with system one

📊 Changes

7 files changed (+201 additions, -47 deletions)

View changed files

📝 Directory.Packages.props (+1 -1)
📝 Jellyfin.Server/Jellyfin.Server.csproj (+1 -1)
Jellyfin.Server/Options.cs (+44 -0)
📝 Jellyfin.Server/Program.cs (+9 -9)
📝 Jellyfin.Server/StartupOptions.cs (+137 -35)
📝 src/Jellyfin.Networking/Jellyfin.Networking.csproj (+4 -0)
📝 tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs (+5 -1)

📄 Description

This PR breaks down the effort started in https://github.com/jellyfin/jellyfin/pull/14422

It is the first step as outlined here, namely:

I also believe we should use System.CommandLine which will become stable in .NET 10 (which Jellyfin 10.12 is pretty much guaranteed to use).

Changes

Ran dotnet add package System.CommandLine --prerelease to get the package.

What I like about this change, on top of the nicer help output, is we got rid of the setters which were superfluous in the first place.

Also, the reflection used allows us to add command line argument fields and properties without forgetting to actually add them to the Command instance.

I took the liberty to silence warnings about the placement of the fields and methods as I find it much more logical to group them by argument name.

Help before:

$ jellyfin --help
Jellyfin.Server 10.10.7.0
Copyright ©  2019 Jellyfin Contributors. Code released under the GNU General Public License

  -d, --datadir             Path to use for the data folder (database files, etc.).

  --nowebclient             Indicates that the web server should not host the web client.

  -w, --webdir              Path to the Jellyfin web UI resources.

  -C, --cachedir            Path to use for caching.

  -c, --configdir           Path to use for configuration data (user settings and pictures).

  -l, --logdir              Path to use for writing log files.

  --ffmpeg                  Path to external FFmpeg executable to use in place of default found in PATH.

  --service                 Run as headless service.

  --package-name            Used when packaging Jellyfin (example, synology).

  --published-server-url    Jellyfin Server URL to publish via auto discover process

  --nonetchange             Indicates that the server should not detect network status change.

  --help                    Display this help screen.

  --version                 Display version information.

Help now:

$ jellyfin --help
Description:
  Jellyfin.Server

Usage:
  jellyfin [options]

Options:
  -d, --datadir <datadir>                        Path to use for the data folder (database files, etc.).
  --nowebclient                                  Indicates that the web server should not host the web
                                                 client.
  -w, --webdir <webdir>                          Path to the Jellyfin web UI resources.
  -C, --cachedir <cachedir>                      Path to use for caching.
  -c, --configdir <configdir>                    Path to use for configuration data (user settings and
                                                 pictures).
  -l, --logdir <logdir>                          Path to use for writing log files.
  --ffmpeg <ffmpeg>                              Path to external FFmpeg executable to use in place of
                                                 default found in PATH.
  --service                                      Run as headless service.
  --packageName <packageName>                    Used when packaging Jellyfin (example, synology).
  --published-server-url <published-server-url>  Jellyfin Server URL to publish via auto discover process.
  --nonetchange                                  Indicates that the server should not detect network status
                                                 change.
  -?, -h, --help                                 Show help and usage information
  --version                                      Show version information

Help with wrong argument before:

$ jellyfin --asd
Jellyfin.Server 10.10.7.0
Copyright ©  2019 Jellyfin Contributors. Code released under the GNU General Public License

ERROR(S):
  Option 'asd' is unknown.

  -d, --datadir             Path to use for the data folder (database files, etc.).

  --nowebclient             Indicates that the web server should not host the web client.

  -w, --webdir              Path to the Jellyfin web UI resources.

  -C, --cachedir            Path to use for caching.

  -c, --configdir           Path to use for configuration data (user settings and pictures).

  -l, --logdir              Path to use for writing log files.

  --ffmpeg                  Path to external FFmpeg executable to use in place of default found in PATH.

  --service                 Run as headless service.

  --package-name            Used when packaging Jellyfin (example, synology).

  --published-server-url    Jellyfin Server URL to publish via auto discover process

  --nonetchange             Indicates that the server should not detect network status change.

  --help                    Display this help screen.

  --version                 Display version information.

Help with wrong argument now:

$ jellyfin --asd
'--asd' was not matched. Did you mean one of the following?
-d

Unrecognized command or argument '--asd'.

Description:
  Jellyfin.Server

Usage:
  jellyfin [options]

Options:
  -d, --datadir <datadir>                        Path to use for the data folder (database files, etc.).
  --nowebclient                                  Indicates that the web server should not host the web
                                                 client.
  -w, --webdir <webdir>                          Path to the Jellyfin web UI resources.
  -C, --cachedir <cachedir>                      Path to use for caching.
  -c, --configdir <configdir>                    Path to use for configuration data (user settings and
                                                 pictures).
  -l, --logdir <logdir>                          Path to use for writing log files.
  --ffmpeg <ffmpeg>                              Path to external FFmpeg executable to use in place of
                                                 default found in PATH.
  --service                                      Run as headless service.
  --packageName <packageName>                    Used when packaging Jellyfin (example, synology).
  --published-server-url <published-server-url>  Jellyfin Server URL to publish via auto discover process.
  --nonetchange                                  Indicates that the server should not detect network status
                                                 change.
  -?, -h, --help                                 Show help and usage information
  --version                                      Show version information

Sanity check run:

$ jellyfin
[23:10:39] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: /home/timi/.cache/jellyfin
[23:10:39] [INF] [9] Jellyfin.Server.ServerSetupApp.SetupServer: Kestrel is listening on 0.0.0.0
[23:10:39] [WRN] [9] Microsoft.AspNetCore.Server.Kestrel: Overriding address(es) 'http://localhost:8096'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
[23:10:39] [INF] [9] Main: Jellyfin version: 10.11.0
[23:10:39] [INF] [9] Main: Environment Variables: ["[ASPNETCORE_URLS, http://localhost:8096]", "[DOTNET_LAUNCH_PROFILE, Jellyfin.Server]", "[ASPNETCORE_ENVIRONMENT, Development]", "[JELLYFIN_LOG_DIR, /home/timi/.local/share/jellyfin/log]", "[DOTNET_ROOT_X64, /nix/store/l50mslybz1g9p3ad5722pv97av52k3dk-dotnet-sdk-9.0.304/share/dotnet]"]
[23:10:39] [INF] [9] Main: Arguments: ["/home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin.dll"]
[23:10:39] [INF] [9] Main: Operating system: NixOS 25.11 (Xantusia)
[23:10:39] [INF] [9] Main: Architecture: X64
[23:10:39] [INF] [9] Main: 64-Bit Process: True
[23:10:39] [INF] [9] Main: User Interactive: True
[23:10:39] [INF] [9] Main: Processor count: 16
[23:10:39] [INF] [9] Main: Program data path: /home/timi/.local/share/jellyfin
[23:10:39] [INF] [9] Main: Log directory path: /home/timi/.local/share/jellyfin/log
[23:10:39] [INF] [9] Main: Config directory path: /home/timi/.config/jellyfin
[23:10:39] [INF] [9] Main: Cache path: /home/timi/.cache/jellyfin
[23:10:39] [INF] [9] Main: Temp directory path: /tmp/jellyfin
[23:10:39] [INF] [9] Main: Web resources path: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin-web
[23:10:39] [INF] [9] Main: Application directory: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/
[23:10:39] [ERR] [9] Main: The server is expected to host the web client, but the provided content directory is either invalid or empty: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin-web. If you do not want to host the web client with the server, you may set the '--nowebclient' command line flag, or set'hostwebclient=false' in your config settings

Issues


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/14813 **Author:** [@ibizaman](https://github.com/ibizaman) **Created:** 9/17/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `cli_parser` --- ### 📝 Commits (1) - [`d1d5335`](https://github.com/jellyfin/jellyfin/commit/d1d5335fd97550aba12c6083338aefb6809c0382) replace command line parser with system one ### 📊 Changes **7 files changed** (+201 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `Directory.Packages.props` (+1 -1) 📝 `Jellyfin.Server/Jellyfin.Server.csproj` (+1 -1) ➕ `Jellyfin.Server/Options.cs` (+44 -0) 📝 `Jellyfin.Server/Program.cs` (+9 -9) 📝 `Jellyfin.Server/StartupOptions.cs` (+137 -35) 📝 `src/Jellyfin.Networking/Jellyfin.Networking.csproj` (+4 -0) 📝 `tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs` (+5 -1) </details> ### 📄 Description This PR breaks down the effort started in https://github.com/jellyfin/jellyfin/pull/14422 It is the first step as outlined [here](https://github.com/jellyfin/jellyfin/pull/14422#issuecomment-3120291849), namely: > I also believe we should use [System.CommandLine](https://github.com/dotnet/command-line-api) which will become stable in .NET 10 (which Jellyfin 10.12 is pretty much guaranteed to use). <!-- Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y). For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our documentation. --> **Changes** Ran `dotnet add package System.CommandLine --prerelease` to get the package. What I like about this change, on top of the nicer help output, is we got rid of the setters which were superfluous in the first place. Also, the reflection used allows us to add command line argument fields and properties without forgetting to actually add them to the `Command` instance. I took the liberty to silence warnings about the placement of the fields and methods as I find it much more logical to group them by argument name. Help before: ``` $ jellyfin --help Jellyfin.Server 10.10.7.0 Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License -d, --datadir Path to use for the data folder (database files, etc.). --nowebclient Indicates that the web server should not host the web client. -w, --webdir Path to the Jellyfin web UI resources. -C, --cachedir Path to use for caching. -c, --configdir Path to use for configuration data (user settings and pictures). -l, --logdir Path to use for writing log files. --ffmpeg Path to external FFmpeg executable to use in place of default found in PATH. --service Run as headless service. --package-name Used when packaging Jellyfin (example, synology). --published-server-url Jellyfin Server URL to publish via auto discover process --nonetchange Indicates that the server should not detect network status change. --help Display this help screen. --version Display version information. ``` Help now: ``` $ jellyfin --help Description: Jellyfin.Server Usage: jellyfin [options] Options: -d, --datadir <datadir> Path to use for the data folder (database files, etc.). --nowebclient Indicates that the web server should not host the web client. -w, --webdir <webdir> Path to the Jellyfin web UI resources. -C, --cachedir <cachedir> Path to use for caching. -c, --configdir <configdir> Path to use for configuration data (user settings and pictures). -l, --logdir <logdir> Path to use for writing log files. --ffmpeg <ffmpeg> Path to external FFmpeg executable to use in place of default found in PATH. --service Run as headless service. --packageName <packageName> Used when packaging Jellyfin (example, synology). --published-server-url <published-server-url> Jellyfin Server URL to publish via auto discover process. --nonetchange Indicates that the server should not detect network status change. -?, -h, --help Show help and usage information --version Show version information ``` Help with wrong argument before: ``` $ jellyfin --asd Jellyfin.Server 10.10.7.0 Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License ERROR(S): Option 'asd' is unknown. -d, --datadir Path to use for the data folder (database files, etc.). --nowebclient Indicates that the web server should not host the web client. -w, --webdir Path to the Jellyfin web UI resources. -C, --cachedir Path to use for caching. -c, --configdir Path to use for configuration data (user settings and pictures). -l, --logdir Path to use for writing log files. --ffmpeg Path to external FFmpeg executable to use in place of default found in PATH. --service Run as headless service. --package-name Used when packaging Jellyfin (example, synology). --published-server-url Jellyfin Server URL to publish via auto discover process --nonetchange Indicates that the server should not detect network status change. --help Display this help screen. --version Display version information. ``` Help with wrong argument now: ``` $ jellyfin --asd '--asd' was not matched. Did you mean one of the following? -d Unrecognized command or argument '--asd'. Description: Jellyfin.Server Usage: jellyfin [options] Options: -d, --datadir <datadir> Path to use for the data folder (database files, etc.). --nowebclient Indicates that the web server should not host the web client. -w, --webdir <webdir> Path to the Jellyfin web UI resources. -C, --cachedir <cachedir> Path to use for caching. -c, --configdir <configdir> Path to use for configuration data (user settings and pictures). -l, --logdir <logdir> Path to use for writing log files. --ffmpeg <ffmpeg> Path to external FFmpeg executable to use in place of default found in PATH. --service Run as headless service. --packageName <packageName> Used when packaging Jellyfin (example, synology). --published-server-url <published-server-url> Jellyfin Server URL to publish via auto discover process. --nonetchange Indicates that the server should not detect network status change. -?, -h, --help Show help and usage information --version Show version information ``` Sanity check run: ``` $ jellyfin [23:10:39] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: /home/timi/.cache/jellyfin [23:10:39] [INF] [9] Jellyfin.Server.ServerSetupApp.SetupServer: Kestrel is listening on 0.0.0.0 [23:10:39] [WRN] [9] Microsoft.AspNetCore.Server.Kestrel: Overriding address(es) 'http://localhost:8096'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead. [23:10:39] [INF] [9] Main: Jellyfin version: 10.11.0 [23:10:39] [INF] [9] Main: Environment Variables: ["[ASPNETCORE_URLS, http://localhost:8096]", "[DOTNET_LAUNCH_PROFILE, Jellyfin.Server]", "[ASPNETCORE_ENVIRONMENT, Development]", "[JELLYFIN_LOG_DIR, /home/timi/.local/share/jellyfin/log]", "[DOTNET_ROOT_X64, /nix/store/l50mslybz1g9p3ad5722pv97av52k3dk-dotnet-sdk-9.0.304/share/dotnet]"] [23:10:39] [INF] [9] Main: Arguments: ["/home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin.dll"] [23:10:39] [INF] [9] Main: Operating system: NixOS 25.11 (Xantusia) [23:10:39] [INF] [9] Main: Architecture: X64 [23:10:39] [INF] [9] Main: 64-Bit Process: True [23:10:39] [INF] [9] Main: User Interactive: True [23:10:39] [INF] [9] Main: Processor count: 16 [23:10:39] [INF] [9] Main: Program data path: /home/timi/.local/share/jellyfin [23:10:39] [INF] [9] Main: Log directory path: /home/timi/.local/share/jellyfin/log [23:10:39] [INF] [9] Main: Config directory path: /home/timi/.config/jellyfin [23:10:39] [INF] [9] Main: Cache path: /home/timi/.cache/jellyfin [23:10:39] [INF] [9] Main: Temp directory path: /tmp/jellyfin [23:10:39] [INF] [9] Main: Web resources path: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin-web [23:10:39] [INF] [9] Main: Application directory: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/ [23:10:39] [ERR] [9] Main: The server is expected to host the web client, but the provided content directory is either invalid or empty: /home/timi/Projects/jellyfin/Jellyfin.Server/bin/Debug/net9.0/jellyfin-web. If you do not want to host the web client with the server, you may set the '--nowebclient' command line flag, or set'hostwebclient=false' in your config settings ``` **Issues** <!-- Tag any issues that this PR solves here. ex. Fixes # --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 07:24:52 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#14128