Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce bskycli #117

Merged
merged 7 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/bskycli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: bskycli

on:
push:
branches: [ "main", release-*, develop ]
pull_request:
branches: [ "main", release-*, develop ]
workflow_dispatch:

jobs:
Linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.x'

- name: Run make linux-x64
run: make bskycli_linux

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- name: Upload package x64
uses: actions/upload-artifact@v4
with:
name: bskycli-linux-x64-${{ steps.gitversion.outputs.FullSemVer }}
path: artifacts/linux-x64

MacOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.x'

- name: Run make osx
run: make bskycli_macos

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- name: Upload package arm64
uses: actions/upload-artifact@v4
with:
name: bskycli-osx-arm64-${{ steps.gitversion.outputs.FullSemVer }}
path: artifacts/osx-arm64

- name: Upload package x64
uses: actions/upload-artifact@v4
with:
name: bskycli-osx-x64-${{ steps.gitversion.outputs.FullSemVer }}
path: artifacts/osx-x64

Windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.x'

- name: Run powershell script
run: |
.\bskycli_publish.ps1

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- name: Upload package x64
uses: actions/upload-artifact@v4
with:
name: bskycli-win-x64-${{ steps.gitversion.outputs.FullSemVer }}
path: artifacts/win-x64

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fishyflip.runsettings
external/Drastic.FlipperKit/build/
src/Frameworks
nuget/
output/
.meteor/
.DS_Store
samples/SandboxApp/Program.cs
Expand Down
113 changes: 113 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,119 @@
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "post",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [
"post",
"Testing ホゲ, etc",
"-r",
"at://did:plc:okblbaji7rz243bluudjlgxt/app.bsky.feed.post/3lc2xksbvhw2f",
"-c",
"bafyreicwud4br5p54vikac7bprpszbca2jjc5ysjkszhtmextdrhgbozoa",
"-e",
"https://github.com/drasticactions/FishyFlip",
"-l",
"en,ja",
"-u",
"${env:BLUESKY_TEST_HANDLE}",
"-p",
"${env:BLUESKY_TEST_PASSWORD}" ],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "post-image",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [
"post",
"image",
"${workspaceFolder}/assets/logo.png,${workspaceFolder}/assets/logo.png",
"-a",
"Testing ホゲ, etc",
"-t",
"Testing ホゲ, etc",
"-r",
"at://did:plc:okblbaji7rz243bluudjlgxt/app.bsky.feed.post/3lc2xksbvhw2f",
"-c",
"bafyreicwud4br5p54vikac7bprpszbca2jjc5ysjkszhtmextdrhgbozoa",
"-l",
"en,ja",
"-u",
"${env:BLUESKY_TEST_HANDLE}",
"-p",
"${env:BLUESKY_TEST_PASSWORD}" ],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "post-video",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [
"post",
"video",
"${workspaceFolder}/assets/video.mp4",
"-vtt",
"${workspaceFolder}/assets/video.en.vtt,${workspaceFolder}/assets/video.ja.vtt",
"-vttl",
"en,ja",
"-r",
"at://did:plc:okblbaji7rz243bluudjlgxt/app.bsky.feed.post/3lc2xksbvhw2f",
"-c",
"bafyreicwud4br5p54vikac7bprpszbca2jjc5ysjkszhtmextdrhgbozoa",
"-u",
"${env:BLUESKY_TEST_HANDLE}",
"-p",
"${env:BLUESKY_TEST_PASSWORD}"
],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "resolve-handle",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [ "resolve-handle", "drasticactions.dev" ],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "did-doc",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [ "did-doc", "did:plc:yhgc5rlqhoezrx6fbawajxlh" ],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "download",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build_bskycli",
"program": "${workspaceFolder}/apps/bskycli/bin/Debug/net9.0/bskycli.dll",
"args": [ "download", "did:plc:urj4pkche2yvpr5ilj4ykteu", "bafkreif2su5dt27u23q2f4tl5mgmojyibl4rj6lundc27sjvtuhawi732y", "-o", "${workspaceFolder}/artifacts/avatar.jpg" ],
"cwd": "${workspaceFolder}/apps/bskycli",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
Expand Down
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build_bskycli",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/apps/bskycli/bskycli.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="ConsoleAppFramework" Version="5.2.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ROOT=$(PWD)
BSKYCLI_ROOT=$(ROOT)/apps/bskycli
BSKYCLI_PROJECT=$(BSKYCLI_ROOT)/bskycli.csproj
BUILD_TYPE=Release
ARTIFACTS_DIR=$(ROOT)/artifacts

bskycli_linux:
rm -rf $(ARTIFACTS_DIR)/linux-x64
dotnet build $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r linux-x64
dotnet publish $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r linux-x64 -o $(ARTIFACTS_DIR)/linux-x64

bskycli_macos_x64:
rm -rf $(ARTIFACTS_DIR)/osx-x64
dotnet build $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r osx-x64
dotnet publish $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r osx-x64 -o $(ARTIFACTS_DIR)/osx-x64

bskycli_macos_arm64:
rm -rf $(ARTIFACTS_DIR)/osx-arm64
dotnet build $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r osx-arm64
dotnet publish $(BSKYCLI_PROJECT) -c $(BUILD_TYPE) -r osx-arm64 -o $(ARTIFACTS_DIR)/osx-arm64

bskycli_macos: bskycli_macos_x64 bskycli_macos_arm64

clean:
rm -rf $(ARTIFACTS_DIR)
98 changes: 98 additions & 0 deletions apps/bskycli/ConsoleLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// <copyright file="ConsoleLog.cs" company="Drastic Actions">
// Copyright (c) Drastic Actions. All rights reserved.
// </copyright>

using Microsoft.Extensions.Logging;

namespace Bskycli;

/// <summary>
/// Console Log.
/// </summary>
public class ConsoleLog
{
private ILogger logger;
private bool verbose;

/// <summary>
/// Initializes a new instance of the <see cref="ConsoleLog"/> class.
/// </summary>
/// <param name="verbose">Verbose logging.</param>
public ConsoleLog(bool verbose)
{
this.verbose = verbose;
this.logger = LoggerFactory.Create(builder =>
{
if (verbose)
{
builder.AddSimpleConsole(options => { options.SingleLine = true; });
builder.SetMinimumLevel(LogLevel.Debug);
}
}).CreateLogger("cli");
}

/// <summary>
/// Gets a value indicating whether the logger is in verbose mode.
/// </summary>
public bool IsVerbose => this.verbose;

/// <summary>
/// Gets the logger.
/// </summary>
public ILogger Logger => this.logger;

/// <summary>
/// Log a message.
/// </summary>
/// <param name="message">Message to log.</param>
public void Log(string message)
{
if (!this.verbose)
{
Console.WriteLine(message);
}

this.logger.LogInformation(message);
}

/// <summary>
/// Log a error message.
/// </summary>
/// <param name="message">Message to log.</param>
public void LogError(string message)
{
if (!this.verbose)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.ResetColor();
}

this.logger.LogError(message);
}

/// <summary>
/// Log a warning message.
/// </summary>
/// <param name="message">Message to log.</param>
public void LogWarning(string message)
{
if (!this.verbose)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(message);
Console.ResetColor();
}

this.logger.LogWarning(message);
}

/// <summary>
/// Log a debug message.
/// </summary>
/// <param name="message">Message to log.</param>
public void LogDebug(string message)
{
this.logger.LogDebug(message);
}
}
Loading
Loading