🐚 Usages of Orbital Shell kernel libraries #31
franck-gaspoz
started this conversation in
Tutorials & how to
Replies: 2 comments
-
1. Bootstrap a shell// some required imports:
using OrbitalShell.Component.CommandLine.Reader;
using System;
using OrbitalShell.Component.CommandLine.Processor;
using OrbitalShell.Component.Console;
using OrbitalShell.Component.Shell;
// ...
// 1. build a clp
var commandLineProcessor = new CommandLineProcessor(
args,
new OrbitalShellCommandLineProcessorSettings()
);
// 2. build a clr associated to the clp
var commandLineReader = new CommandLineReader( commandLineProcessor );
// 3. invoke a shell initializer to bootsrap a shell env associated to the clp
var shellInitializer = new ShellInitializer(commandLineProcessor);
shellInitializer.Run(commandLineProcessor.CommandEvaluationContext);
// 4. run the interactive shell
var returnCode = commandLineReader.ReadCommandLine();
Environment.Exit(returnCode); |
Beta Was this translation helpful? Give feedback.
0 replies
-
2. Ways to invoke a shell command from C# through shell APIs2.1. Invoke within a command line text (no library coupling but dependent of com syntax)// context is CommandEvaluationContext
var res = context.CommandLineProcessor.Eval(context, "nuget-ver orbitalshell-module-promptgitinfo -q"); 2.2 Invoke within a reference to the type and the command method (coupling with library, dependent of com syntax)var getVerMethod = typeof(NuGetServerApiCommands).GetMethod("NugetVer");
var res = context.CommandLineProcessor.Eval(context, getVerMethod, "orbitalshell-module-promptgitinfo -q" ); 2.3 Invoke directly having a command declaring type instance (max coupling to the com declaring type, independent of syntax)// this will be the preferred method once DI is integrated in the architecture of the shell
var res = nuGetServerApiCommands.NugetVer(context,"orbitalshell-module-promptgitinfo",true); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Collect and share code snippets related to the usage of shell kernel libraries that would be usefull for any development ⛱️ 🌊 🐚
avoid headaches, find directly the code snipet you need
Beta Was this translation helpful? Give feedback.
All reactions