Repository navigation
Feature/cli simplification - #406
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ation # Conflicts: # src/OneWare.Core/OneWare.Core.csproj # src/OneWare.Essentials/OneWare.Essentials.csproj
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add CLI
Adds a command-line interface to OneWare Studio. The commands run inside the existing
OneWareStudioexecutable, so there is no separate CLI binary, launcher script or packaging change. Plugins can add their own commands.How it works
CLI dispatch (
studio/OneWare.Studio.Desktop/Cli)Program.MaincallsStudioCli.IsCliInvocation(args)before Avalonia starts. The CLI runs when the first positional argument looks like a command name (letters, digits,-,_) and is not an existing file or folder, or when--help/--versionis passed. Anything else (no arguments, a path, aoneware://URL) starts the GUI as before.--oneware-dir,--modules,--autolaunch,-C/--working-directory, …) moved toOneWareStartupCommandLineand are shared by the GUI and the CLI.StudioCliModule(stop),ExtensionStoreCliModuleandOneWareCloudCliModule. Plugin CLI modules are discovered by reflection; this is skipped forextensionscommands so a broken plugin can still be removed.Windows:
oneware.exeOneWareStudio.exeis a GUI-subsystem app (WinExe), so it can't write to the terminal it was started from or return an exit code there. The build and publish steps createoneware.exe: a copy of the same small .NET launcher with the PESubsystemfield patched to console (SetPeConsoleSubsysteminline task, one changed byte). It loads the sameOneWareStudio.dll. Without a command,oneware.exestartsOneWareStudio.exeas a separate process. The MSI already puts the install folder onPATH.Plugin API (
OneWare.Essentials, additions only)IOneWareCliModule/OneWareCliModuleBase: register services and top-levelSystem.CommandLinecommands. Command names must be plain words.IIpcCommandService: GUI modules register handlers for commands sent to the running Studio.StudioInstanceChannel: the single-instance lock plus IPC channel, so CLI modules can callIsStudioRunning(),SendCommandAsync(name, arg)andWaitForExitAsync().ISettingsService.SaveValues(path, values): updates individual keys in the settings file without overwriting the rest (used by the CLI while Studio may be running).Single instance and IPC (reworked)
%TEMP%\OneWareand pipeoneware-studio-ipc-<user>on Windows,$XDG_RUNTIME_DIR/oneware(fallback/tmp/oneware-<user>, mode 0700) on Linux,$TMPDIR/OneWareon macOS. Unix sockets live in that directory, andPipeOptions.CurrentUserOnlyis used everywhere. Previously, two users on the same Linux machine blocked each other.cmd:<name>[\n<arg>]. Plain paths,oneware://URLs and the oldactivateWindowmessage still work.Commands that affect a running Studio
oneware stopsendsshutdownand waits up to 10 s for the lock to be released. If Studio is waiting on an unsaved-changes dialog, the command says so and exits 1.oneware cloud login|logoutwrites the account setting and notifies a running Studio (cloud-login <userId>/cloud-logout), so its next settings save no longer reverts the change.Plugin loading
PluginServiceassembly and native-library loading moved intoPluginAssemblyLoader/PluginNativeLibraryResolverso the CLI can load plugins without the GUI.Compatibility notes
.desktop) or the MSI layout; the executable name and theoneware://association are unchanged.System.CommandLine3.0.0-rc.1(a pre-release) is now referenced by Essentials and is part of the plugin API throughIOneWareCliModule. Core previously used 2.0.2.ISettingsService.SaveValueshas no default implementation, so third-partyISettingsServiceimplementations (unlikely) would break.Testing
StudioInstanceChannelTests(message format, lock probe, send/receive including a 20-message burst),IpcCommandServiceTests,StudioCliTests(CLI vs. GUI argument detection),ExtensionStoreCliModuleTests,PluginNativeLibraryResolverTests.dotnet test OneWare.slnxpass.win-x64publish producesoneware.exewith subsystem 3 (only one byte differs fromOneWareStudio.exe).--help, an unknown command (exit 1),-C <dir> stop, andstopwith no Studio running or with an unreachable instance.Follow-ups (not in this PR)
System.CommandLinerelease before shipping the plugin API.extensions install/uninstallshould behave while Studio is running.