Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Update readme for uninstall command
Browse files Browse the repository at this point in the history
  • Loading branch information
devklick committed May 6, 2024
1 parent 2313289 commit e188a4b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ gdman install --latest --flavour standard
```

> [!NOTE]
> The shorthand option for `--flavour` is `-f`
> The shorthand option for `--flavour` is `-fl`
### Installing the correct version for your platform

Expand Down Expand Up @@ -177,3 +177,29 @@ gdman uninstall --unused

> [!NOTE]
> The shorthand command for `--unused` is `-u`
### Uninstall specific version(s)

If you want to uninstall one or more specific versions, you can use the `--version`
option to specify which versions should be uninstalled. Any valid semver version
range is supported.

For example, uninstall all major version 3:

```
gdman uninstall --version 3
```

If you're uninstalling multiple versions using the `--version` option, you will
need to include the `--force | -f` flag. Without this, the application will print
the versions that have been found for uninstall but not uninstall them. This is only
required when multiple versions have been identified matching the input options.

> [!NOTE]
> The shorthand command for `--version` is `-v`
### Other uninstall options

The uninstall command also optionally supports `--platform`, `-architecture` and
`--flavour`, just like the install command does. If you do not specify these,
the application will look for all versions matching the other specified options.
2 changes: 1 addition & 1 deletion src/GDMan.Cli/Options/InstallOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class InstallOptions : BaseOptions
[Option("architecture", "a", "The system architecture to find a version for", OptionDataType.Enum)]
public Architecture Architecture { get; set; } = ArchitectureHelper.FromEnvVar() ?? ArchitectureHelper.FromSystem();

[Option("flavour", "f", "The \"flavour\" (for lack of a better name) of version to use", OptionDataType.Enum)]
[Option("flavour", "fl", "The \"flavour\" (for lack of a better name) of version to use", OptionDataType.Enum)]
public Flavour Flavour { get; set; } = FlavourHelper.FromEnvVar() ?? Flavour.Standard;

public override OptionValidation Validate()
Expand Down
4 changes: 2 additions & 2 deletions src/GDMan.Cli/Options/UninstallOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public class UninstallOptions : BaseOptions
[Option("architecture", "a", "The system architecture to find a version for", OptionDataType.Enum)]
public Architecture? Architecture { get; set; }

[Option("flavour", "f", "The \"flavour\" (for lack of a better name) of version to use", OptionDataType.Enum)]
[Option("flavour", "fl", "The \"flavour\" (for lack of a better name) of version to use", OptionDataType.Enum)]
public Flavour? Flavour { get; set; }

[Option("flavour", "f", "The \"flavour\" (for lack of a better name) of version to use", OptionDataType.Enum)]
[Option("force", "f", "Allows multiple versions matching the --version criteria to be uninstalled", OptionDataType.Boolean, isFlag: true)]
public bool Force { get; set; } = false;

[Option("unused", "u", "Install all versions other than the currently-active version", OptionDataType.Boolean, isFlag: true)]
Expand Down
22 changes: 20 additions & 2 deletions src/GDMan.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using GDMan.Core.Services.Github;
using GDMan.Core.Services.FileSystem;
using GDMan.Core.Infrastructure;
using GDMan.Core.Models;

namespace GDMan.Cli;

Expand Down Expand Up @@ -79,7 +80,7 @@ private static async Task RunUninstallAsync(UninstallOptions command)
{
_logger.LogTrace("Processing uninstall command");

await _godot.UninstallAsync(
var result = await _godot.UninstallAsync(
command.Version,
command.Platform,
command.Architecture,
Expand All @@ -88,21 +89,25 @@ await _godot.UninstallAsync(
command.Unused
);

HandleResult(result);

_logger.LogTrace("Done");
}

private static async Task RunInstallAsync(InstallOptions command)
{
_logger.LogTrace($"Processing install command");

await _godot.InstallAsync(
var result = await _godot.InstallAsync(
command.Version,
command.Latest,
command.Platform,
command.Architecture,
command.Flavour
);

HandleResult(result);

_logger.LogTrace("Done");
}

Expand Down Expand Up @@ -146,4 +151,17 @@ private static void HandleException(Exception ex)
_logger.LogFatal(ex);
Environment.Exit(1);
}

private static void HandleResult<T>(Result<T> result)
{
if (result.Messages.Any())
{
var level = result.Status == ResultStatus.OK ? LogLevel.Information : LogLevel.Error;
result.Messages.ForEach(message => _logger.Log(level, message));
}
if (result.Status != ResultStatus.OK)
{
Environment.Exit(1);
}
}
}
3 changes: 3 additions & 0 deletions src/GDMan.Core/Services/GodotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ public async Task<Result<object>> UninstallAsync(SemanticVersioning.Range? versi
}

if (remove.Count == 0)
{
_logger.LogInformation("No versions found to uninstall");
return new Result<object> { Status = ResultStatus.OK };
}

_logger.LogInformation("Found the following versions to uninstall");

Expand Down

0 comments on commit e188a4b

Please sign in to comment.