feat: update nuspec metadata and add PATH setup functionality for terminal access

This commit is contained in:
HueByte
2026-02-24 19:44:55 +01:00
parent 045515369c
commit 6295831045
4 changed files with 151 additions and 22 deletions
+11 -11
View File
@@ -4,21 +4,21 @@
<id>echohub</id> <id>echohub</id>
<version>__VERSION__</version> <version>__VERSION__</version>
<title>EchoHub</title> <title>EchoHub</title>
<authors>Hue</authors> <authors>HueByte</authors>
<owners>Hue</owners> <owners>HueByte</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://github.com/HueByte/EchoHub/blob/master/LICENSE</licenseUrl> <licenseUrl>https://github.com/HueByteByte/EchoHub/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/HueByte/EchoHub</projectUrl> <projectUrl>https://github.com/HueByteByte/EchoHub</projectUrl>
<projectSourceUrl>https://github.com/HueByte/EchoHub</projectSourceUrl> <projectSourceUrl>https://github.com/HueByteByte/EchoHub</projectSourceUrl>
<docsUrl>https://huebyte.github.io/EchoHub</docsUrl> <docsUrl>https://HueBytebyte.github.io/EchoHub</docsUrl>
<bugTrackerUrl>https://github.com/HueByte/EchoHub/issues</bugTrackerUrl> <bugTrackerUrl>https://github.com/HueByteByte/EchoHub/issues</bugTrackerUrl>
<packageSourceUrl>https://github.com/HueByte/EchoHub/tree/master/packaging/choco</packageSourceUrl> <packageSourceUrl>https://github.com/HueByteByte/EchoHub/tree/master/packaging/choco</packageSourceUrl>
<iconUrl>https://raw.githubusercontent.com/HueByte/EchoHub/master/assets/hue_icon.png</iconUrl> <iconUrl>https://raw.githubusercontent.com/HueByteByte/EchoHub/master/assets/HueByte_icon.png</iconUrl>
<description>EchoHub is a decentralized IRC-style chat application with a terminal user interface (TUI). Connect to any EchoHub server, join channels, and chat — all from your terminal. Features include SignalR real-time messaging, file sharing, custom themes, and IRC gateway compatibility.</description> <description>EchoHub is a decentralized IRC-style chat application with a terminal user interface (TUI). Connect to any EchoHub server, join channels, and chat — all from your terminal. Features include SignalR real-time messaging, file sharing, custom themes, and IRC gateway compatibility.</description>
<summary>Decentralized terminal chat client with IRC gateway support</summary> <summary>Decentralized terminal chat client with IRC gateway support</summary>
<tags>chat irc decentralized tui terminal signalr echohub</tags> <tags>chat irc decentralized tui terminal signalr echohub</tags>
<releaseNotes>https://huebyte.github.io/EchoHub/changelog/v__VERSION__.html</releaseNotes> <releaseNotes>https://HueBytebyte.github.io/EchoHub/changelog/v__VERSION__.html</releaseNotes>
<copyright>Copyright (c) 2026 Hue</copyright> <copyright>Copyright (c) 2026 HueByte</copyright>
</metadata> </metadata>
<files> <files>
<file src="tools\**" target="tools" /> <file src="tools\**" target="tools" />
+33 -9
View File
@@ -130,6 +130,31 @@ download() {
fi fi
} }
# ── PATH setup ────────────────────────────────────────────────────────────
add_to_path() {
dir="$1"
export_line="export PATH=\"${dir}:\$PATH\" # Added by EchoHub"
added=0
for profile in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.zshrc"; do
if [ -f "$profile" ]; then
if grep -q "$dir" "$profile" 2>/dev/null; then
continue # Already present
fi
printf '\n%s\n' "$export_line" >> "$profile"
echo " Added to PATH in $(basename "$profile")"
added=1
fi
done
# If no profile existed, create .profile
if [ "$added" -eq 0 ]; then
printf '\n%s\n' "$export_line" >> "$HOME/.profile"
echo " Added to PATH in .profile"
fi
}
# ── Main ────────────────────────────────────────────────────────────────── # ── Main ──────────────────────────────────────────────────────────────────
main() { main() {
@@ -181,18 +206,17 @@ main() {
echo "" echo ""
# Verify # Ensure install directory is on PATH
if command -v "$BINARY_NAME" >/dev/null 2>&1; then if ! command -v "$BINARY_NAME" >/dev/null 2>&1; then
add_to_path "$install_dir"
fi
echo "Installed successfully! Run 'echohub' to start." echo "Installed successfully! Run 'echohub' to start."
else
echo "Installed to: ${install_dir}/${BINARY_NAME}"
echo "" echo ""
echo "WARNING: ${install_dir} is not in your PATH." if ! echo "$PATH" | tr ':' '\n' | grep -qx "$install_dir"; then
echo "Add it to your shell profile:" echo "NOTE: Restart your shell or run the following to use echohub now:"
echo "" echo ""
echo " echo 'export PATH=\"${install_dir}:\$PATH\"' >> ~/.bashrc" echo " export PATH=\"${install_dir}:\$PATH\""
echo " # or for zsh:"
echo " echo 'export PATH=\"${install_dir}:\$PATH\"' >> ~/.zshrc"
fi fi
} }
+3
View File
@@ -77,6 +77,9 @@ Log.Logger = new LoggerConfiguration()
Log.Information("EchoHub client starting"); Log.Information("EchoHub client starting");
// == Ensure echohub is on PATH for convenient terminal access ============
PathSetup.EnsureOnPath();
// == Post-update detection: stale backup cleanup or flag for rollback menu ================ // == Post-update detection: stale backup cleanup or flag for rollback menu ================
if (UpdateBackupService.BackupExists()) if (UpdateBackupService.BackupExists())
{ {
+102
View File
@@ -0,0 +1,102 @@
using Serilog;
namespace EchoHub.Client.Services;
/// <summary>
/// Ensures the application's directory is on the system PATH so users
/// can run 'echohub' from any terminal session.
/// </summary>
public static class PathSetup
{
private const string PathMarker = "# Added by EchoHub";
/// <summary>
/// Checks if the app directory is on PATH; if not, adds it persistently.
/// On Windows: modifies user-level PATH environment variable.
/// On Linux/macOS: appends an export line to shell profile files.
/// </summary>
public static void EnsureOnPath()
{
try
{
var appDir = AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
if (IsOnPath(appDir))
return;
if (OperatingSystem.IsWindows())
AddToWindowsPath(appDir);
else
AddToUnixPath(appDir);
}
catch (Exception ex)
{
Log.Debug(ex, "Could not add app directory to PATH");
}
}
private static bool IsOnPath(string directory)
{
var pathVar = Environment.GetEnvironmentVariable("PATH") ?? "";
var separator = OperatingSystem.IsWindows() ? ';' : ':';
return pathVar
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.Any(p => string.Equals(
p.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar),
directory,
OperatingSystem.IsWindows()
? StringComparison.OrdinalIgnoreCase
: StringComparison.Ordinal));
}
private static void AddToWindowsPath(string directory)
{
var userPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) ?? "";
// Double-check against user PATH specifically (process PATH includes system + user)
if (userPath.Split(';', StringSplitOptions.RemoveEmptyEntries)
.Any(p => string.Equals(p.TrimEnd('\\', '/'), directory, StringComparison.OrdinalIgnoreCase)))
return;
var newPath = string.IsNullOrEmpty(userPath) ? directory : userPath + ";" + directory;
Environment.SetEnvironmentVariable("PATH", newPath, EnvironmentVariableTarget.User);
Log.Information("Added {Directory} to user PATH", directory);
}
private static void AddToUnixPath(string directory)
{
var exportLine = $"export PATH=\"{directory}:$PATH\" {PathMarker}";
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
// Target the most common shell profiles
string[] profiles = [
Path.Combine(home, ".profile"),
Path.Combine(home, ".bashrc"),
Path.Combine(home, ".zshrc")
];
var added = false;
foreach (var profile in profiles)
{
if (!File.Exists(profile))
continue;
var content = File.ReadAllText(profile);
if (content.Contains(directory))
continue; // Already present (manual or previous run)
File.AppendAllText(profile, $"\n{exportLine}\n");
added = true;
Log.Information("Added PATH export to {Profile}", profile);
}
// If no profile existed, create .profile
if (!added)
{
var fallback = Path.Combine(home, ".profile");
File.AppendAllText(fallback, $"\n{exportLine}\n");
Log.Information("Created PATH export in {Profile}", fallback);
}
}
}