chore: lots of chores

This commit is contained in:
Stevan Freeborn
2025-08-19 16:25:15 -05:00
parent 3752e9dfa0
commit bd0a7fe3cd
23 changed files with 97 additions and 33 deletions
@@ -1,9 +1,8 @@
using System.Text.Json;
using StreamShorts.Library.Media.Video;
namespace StreamShorts.Console.Commands;
/// <summary>
/// The default command for processing video streams to create short clips.
/// </summary>
internal sealed class DefaultCommand(
IFileSystem fileSystem,
IAnsiConsole console,
@@ -28,8 +27,14 @@ internal sealed class DefaultCommand(
private readonly IShortsCreator _shortsCreator = shortsCreator ?? throw new ArgumentNullException(nameof(shortsCreator));
private readonly TimeProvider _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
/// <summary>
/// Represents the settings for the default command.
/// </summary>
internal class Settings : CommandSettings
{
/// <summary>
/// Gets or sets the path to the stream.
/// </summary>
[CommandArgument(0, "[Stream]")]
[Description("The path to the stream")]
public string Stream { get; init; } = string.Empty;
@@ -103,7 +108,7 @@ internal sealed class DefaultCommand(
);
_fileSystem.Directory.CreateDirectory(outputDirectoryPath);
await _fileSystem.File.WriteAllTextAsync(
_fileSystem.Path.Combine(outputDirectoryPath, "transcription.txt"),
string.Join(Environment.NewLine, transcriptionSegments)
@@ -1,7 +1,15 @@
namespace StreamShorts.Console.Hosting;
/// <summary>
/// Provides extension methods for building command applications from host builders.
/// </summary>
internal static class HostBuilderExtensions
{
/// <summary>
/// Builds a command application from the host builder.
/// </summary>
/// <param name="builder">The host builder.</param>
/// <returns>A configured command application.</returns>
public static CommandApp<DefaultCommand> BuildApp(this IHostBuilder builder)
{
var registrar = new TypeRegistrar(builder);
@@ -1,5 +1,9 @@
namespace StreamShorts.Console.Hosting;
/// <summary>
/// Provides type registration services for the dependency injection container.
/// </summary>
/// <inheritdoc/>
internal sealed class TypeRegistrar(IHostBuilder builder) : ITypeRegistrar
{
private readonly IHostBuilder _builder = builder;
@@ -1,5 +1,9 @@
namespace StreamShorts.Console.Hosting;
/// <summary>
/// Provides type resolution services using the dependency injection container.
/// </summary>
/// <inheritdoc/>
internal sealed class TypeResolver(IHost provider) : ITypeResolver, IDisposable
{
private readonly IHost _host = provider ?? throw new ArgumentNullException(nameof(provider));
+3 -7
View File
@@ -1,8 +1,4 @@
using Microsoft.Extensions.Configuration;
using StreamShorts.Library.Media.Video;
Log.Logger = new LoggerConfiguration()
Log.Logger = new LoggerConfiguration()
.WriteTo.File(
formatter: new CompactJsonFormatter(),
path: Path.Combine(AppContext.BaseDirectory, "logs", "log.jsonl"),
@@ -42,7 +38,7 @@ try
{
throw new InvalidOperationException($"{keyOptionName} is not configured in appsettings.json.");
}
var clientFactory = sp.GetRequiredService<IHttpClientFactory>();
return new GeminiAnalyzer(clientFactory, key, model);
@@ -62,4 +58,4 @@ catch (Exception ex)
finally
{
await Log.CloseAndFlushAsync();
}
}
@@ -1,7 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>StreamShorts.Console</AssemblyTitle>
<Product>StreamShorts.Console</Product>
<Description>A command-line interface for StreamShorts</Description>
<Version>0.0.0</Version>
<Authors>Stevan Freeborn</Authors>
<OutputType>Exe</OutputType>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>
<ItemGroup>
+4 -1
View File
@@ -1,7 +1,9 @@
global using System.ComponentModel;
global using System.IO.Abstractions;
global using System.Reflection;
global using System.Text.Json;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
@@ -18,4 +20,5 @@ global using StreamShorts.Console.Hosting;
global using StreamShorts.Library.Analysis;
global using StreamShorts.Library.Analysis.Gemini;
global using StreamShorts.Library.Media.Audio;
global using StreamShorts.Library.Transcription;
global using StreamShorts.Library.Media.Video;
global using StreamShorts.Library.Transcription;