Skip to content

Commit

Permalink
Merge pull request #44 from OrbitalShell/feature-startup-args
Browse files Browse the repository at this point in the history
Feature startup args
  • Loading branch information
franck-gaspoz authored Mar 29, 2021
2 parents 5bbe732 + 03e8d84 commit afea6b4
Show file tree
Hide file tree
Showing 39 changed files with 1,317 additions and 366 deletions.
77 changes: 77 additions & 0 deletions OrbitalShell-CLI/Component/Shell/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
// map shell environment variables and namespaces

"env": {

"debug": {

"enableHookTrace": false,
"enablePipelineTrace": false

},

"settings": {

"clp": {

"enableShellExecTraceProcessStart": false,
"enableShellExecTraceProcessEnd": false,
"shellExecBatchExt": ".sh"

},

"clr": {

"comPreAnalysisOutput": "\r\n",
"comPostExecOutModifiedOutput": "\r\n",
"comPostExecOutput": ""

},

"console": {

"prompt": "> ",
"initialWindowWidth": -1,
"initialWindowHeight": -1,
"enableCompatibilityMode": false,
"enableAvoidEndOfLineFilledWithBackgroundColor": true,

"banner": {

"path": "./Commands/CommandLineProcessor/banner-4.txt",
"isEnabled": true,
"startColorIndex": 21,
"startColorIndex2": 49,
"colorIndexStep": 6
}

},

"module": {

"providerUrls": [
"https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/master/module-index-repository/module-list.json",
"https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/dev/module-index-repository/module-list.json"
]

}

},

"display": {

}
},

"local": {

},

"global": {

},

"_": {

}
}
10 changes: 9 additions & 1 deletion OrbitalShell-CLI/OrbitalShell-CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down Expand Up @@ -95,6 +95,11 @@

</ItemGroup>


<ItemGroup>
<Compile Remove="ServicesInitializer.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OrbitalShell-ConsoleApp\OrbitalShell-ConsoleApp.csproj" />
<ProjectReference Include="..\OrbitalShell-Kernel\OrbitalShell-Kernel.csproj" />
Expand All @@ -108,6 +113,9 @@
<PackagePath>contentFiles/any/net5.0/Component/Shell/Defaults/;content/Component/Shell/Defaults/</PackagePath>
<PackageCopyToOutput>true</PackageCopyToOutput>
</None>
<None Update="Component\Shell\settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="scripts\publish-cli-release.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
43 changes: 18 additions & 25 deletions OrbitalShell-CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
using System.Threading.Tasks;


using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using OrbitalShell.Component.Shell;
using OrbitalShell.Component.CommandLine.Processor;
using OrbitalShell.Component.Shell.Init;

namespace OrbitalShell
{
public static class Program
{
static async Task<int> Main(string[] args)
=> await RunShell(args);

public static async Task<int> RunShell(string[] args)
static int Main(string[] args)
{
var shellStartup = InitializeShell(args);

var returnCode = shellStartup.Startup(args);
var returnCode =
GetShellServiceHost(args)
.RunShellServiceHost(args);

await App.Host.RunAsync();
App.Host.Run();

return returnCode;
}

public static IShellStartup InitializeShell(string[] args)
{
App.InitializeServices(System.Array.Empty<string>());

var si = new ServicesInitializer();
si.InitializeServices(App.HostBuilder);

App.EndInitializeServices();

var scope = App.Host.Services.CreateScope();
si.ScopedServiceProvider = scope.ServiceProvider;

return scope.ServiceProvider.GetRequiredService<IShellStartup>();
}
public static IShellServiceHost GetShellServiceHost(string[] args)
=> ShellServiceHost.GetShellServiceHost(
args,
(hostBuilder) =>
hostBuilder.ConfigureServices(
(_, services) =>
services.AddScoped
<ICommandLineProcessorSettings, OrbitalShellCommandLineProcessorSettings>()
)
);
}
}

61 changes: 0 additions & 61 deletions OrbitalShell-CLI/ShellStartup.cs

This file was deleted.

Loading

0 comments on commit afea6b4

Please sign in to comment.