-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More commands and an initial GH action
- Loading branch information
Showing
18 changed files
with
143 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: build | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # get entire git tree, required for nerdbank gitversioning | ||
- name: Get version | ||
shell: pwsh | ||
run: | | ||
cd src | ||
$version = (nbgv get-version -f json | ConvertFrom-Json).SimpleVersion | ||
Write-Host "Version $version" | ||
Write-Output "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
# - name: Login to GitHub Container Registry | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.actor }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
# - name: Build the hello-docker Docker image | ||
# run: | | ||
# docker build . --tag ghcr.io/g3rv4/fakerelay:latest | ||
# docker run ghcr.io/deselikem/hello-docker-gcr-demo:latest | ||
# docker push ghcr.io/deselikem/hello-docker-gcr-demo:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ obj/ | |
*.csproj.user | ||
launchSettings.json | ||
.idea/ | ||
config.json | ||
config-tokens.json | ||
data/ | ||
.DS_Store | ||
DataDir* | ||
.build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using FakeRelay.Cli.Settings; | ||
using FakeRelay.Core; | ||
using FakeRelay.Core.Helpers; | ||
using Spectre.Console.Cli; | ||
|
||
namespace FakeRelay.Cli.Commands; | ||
|
||
public class ConfigCommand: Command<ConfigSettings> | ||
{ | ||
public override int Execute(CommandContext context, ConfigSettings settings) | ||
{ | ||
var configPath = Environment.GetEnvironmentVariable("CONFIG_PATH"); | ||
if (File.Exists(configPath)) | ||
{ | ||
throw new Exception("There's a config file"); | ||
} | ||
|
||
var (pub, priv) = CryptographyHelper.GenerateKeys(); | ||
Config.CreateConfig(configPath, settings.Host, pub, priv); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using FakeRelay.Core; | ||
using Spectre.Console.Cli; | ||
|
||
namespace FakeRelay.Cli.Commands; | ||
|
||
public abstract class ConfigEnabledAsyncCommand<T> : AsyncCommand<T> | ||
where T : CommandSettings | ||
{ | ||
protected ConfigEnabledAsyncCommand() | ||
{ | ||
Config.Init(Environment.GetEnvironmentVariable("CONFIG_PATH")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
using FakeRelay.Cli.Commands; | ||
using FakeRelay.Core; | ||
using Spectre.Console.Cli; | ||
|
||
var app = new CommandApp(); | ||
app.Configure(config => | ||
{ | ||
config.AddCommand<AddHostCommand>("add-host"); | ||
config.AddCommand<AddHostCommand>("add-host") | ||
.WithDescription("Adds a host to the relay and generates a key.") | ||
.WithExample(new[] {"mastodon.social"}); | ||
|
||
config.AddCommand<UpdateHostCommand>("update-host"); | ||
config.AddCommand<DeleteHostCommand>("delete-host"); | ||
config.AddCommand<ConfigCommand>("config"); | ||
}); | ||
|
||
Config.Init(Environment.GetEnvironmentVariable("CONFIG_PATH")); | ||
|
||
return app.Run(args); | ||
return app.Run(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel; | ||
using Spectre.Console.Cli; | ||
|
||
namespace FakeRelay.Cli.Settings; | ||
|
||
public class ConfigSettings : CommandSettings | ||
{ | ||
[Description("The hostname of the relay.")] | ||
[CommandArgument(0, "<HOST>")] | ||
public string Host { get; set; } | ||
} |
6 changes: 4 additions & 2 deletions
6
src/FakeRelay.Cli/HostSettings.cs → src/FakeRelay.Cli/Settings/HostSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using System.ComponentModel; | ||
using Spectre.Console.Cli; | ||
|
||
namespace FakeRelay.Cli; | ||
namespace FakeRelay.Cli.Settings; | ||
|
||
public class HostSettings : CommandSettings | ||
{ | ||
[Description("The instance that connects to this fake relay.")] | ||
[CommandArgument(0, "<HOST>")] | ||
public string Host { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters