├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ ├── dotnet.yml │ ├── greetings.yml │ └── publish-dockerhub.yml ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── OrbitalShell-CLI ├── .gitattributes ├── .gitignore ├── .vscode │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── Component │ ├── CommandLine │ │ └── Processor │ │ │ └── CommandLineProcessorSettings.cs │ └── Shell │ │ ├── Defaults │ │ └── .profile │ │ └── settings.json ├── LICENSE.md ├── OrbitalShell-CLI.csproj ├── Program.cs ├── Properties │ └── launchSettings.json ├── README.md ├── assets │ ├── robotazteque.ico │ └── robotazteque.png ├── build │ ├── OrbitalShell-linux-arm.nuspec │ ├── OrbitalShell-linux-arm64.nuspec │ ├── OrbitalShell-linux-musl-x64.nuspec │ ├── OrbitalShell-linux-x64.nuspec │ ├── OrbitalShell-osx-x64.nuspec │ ├── OrbitalShell-win-x64.nuspec │ └── OrbitalShell.nuspec ├── data │ └── emojis.json └── scripts │ ├── com-dev-notes.sh │ ├── commands.sh │ ├── echo-directives-test.txt │ ├── prompt-samples.sh │ ├── publish-binaries.sh │ ├── publish-cli-release.sh │ ├── publish-kernel-packages.sh │ └── unicode-boxes.sh ├── OrbitalShell-ConsoleApp ├── .gitattributes ├── .gitignore ├── App.cs ├── Component │ ├── Console │ │ ├── ANSI.cs │ │ ├── ASCII.cs │ │ ├── ActualWorkArea.cs │ │ ├── BufferedOperationNotAvailableException.cs │ │ ├── Color4BitMap.cs │ │ ├── ColorSettings.cs │ │ ├── ConsoleTextWriterWrapper.cs │ │ ├── EchoSequence.cs │ │ ├── EchoSequenceList.cs │ │ ├── InputMap.cs │ │ ├── LineSplitList.cs │ │ ├── StringSegment.cs │ │ ├── TextColor.cs │ │ ├── TextWriterWrapper.cs │ │ ├── Unicode.cs │ │ └── WorkArea.cs │ ├── EchoDirective │ │ ├── CommandMap.cs │ │ ├── EchoDirectiveProcessor.cs │ │ ├── EchoDirectives.cs │ │ └── Shortcuts.cs │ ├── Parser │ │ ├── ANSI │ │ │ ├── ANSIParser.cs │ │ │ └── ansi-seq-patterns.txt │ │ ├── Json │ │ │ └── JsonEventParser.cs │ │ └── NonRecursiveFunctionalGrammar │ │ │ ├── NonRecursiveFunctionGrammarParser.cs │ │ │ ├── Rule.cs │ │ │ ├── SyntacticBlock.cs │ │ │ ├── SyntacticBlockList.cs │ │ │ ├── TreeNode.cs │ │ │ └── TreePath.cs │ ├── Script │ │ └── CSharpScriptEngine.cs │ ├── Settings │ │ └── SettingsBuilder.cs │ └── UI │ │ └── WorkAreaScrollEventArgs.cs ├── Console.cs ├── Doc │ └── Images │ │ ├── 2020-06-13 02_34_57-Window-github.png │ │ ├── 2020-06-13 06_18_08-Window.png │ │ ├── 2020-06-13 06_36_43-Window.png │ │ └── orbital-shell.png ├── IConsole.cs ├── LICENSE.md ├── Lib │ ├── EventArgs.cs │ ├── Process │ │ ├── ProcessCounter.cs │ │ └── ProcessWrapper.cs │ ├── RuntimeEnvironment.cs │ ├── Str.cs │ ├── StrExt.cs │ ├── TargetPlatform.cs │ ├── TextFileReader.cs │ ├── TypeExt.cs │ └── TypesManglingExt.cs ├── OrbitalShell-ConsoleApp.csproj ├── README.md ├── Temp │ └── this is an embeded temp folder.txt └── assets │ └── robotazteque.png ├── OrbitalShell-Kernel-Commands ├── Commands │ ├── CommandLineProcessor │ │ ├── banner-2.txt │ │ ├── banner-3.txt │ │ ├── banner-4.txt │ │ └── banner.txt │ ├── ConsoleCommands.cs │ ├── DevCommands.cs │ ├── FileSystem │ │ ├── DirSort.cs │ │ └── FileSystemCommands.cs │ ├── Http │ │ ├── HttpCommands.cs │ │ └── HttpContentBody.cs │ ├── NuGetServerApi │ │ ├── NuGetServerApiCommands.cs │ │ ├── Package.cs │ │ ├── PackageType.cs │ │ ├── PackageVersionInfos.cs │ │ ├── PackageVersions.cs │ │ └── QueryResultRoot.cs │ ├── Shell │ │ ├── ShellCommands.cs │ │ ├── ShellCommands_Help.cs │ │ ├── ShellCommands_Hist.cs │ │ ├── ShellCommands_Mod.cs │ │ └── ShellCommands_Var.cs │ ├── SystemCommands.cs │ ├── Test │ │ └── TestCommands.cs │ ├── TextEditor │ │ ├── EditorBackup.cs │ │ ├── TextEditor.cs │ │ └── edit-help.txt │ ├── TextFile │ │ ├── TextFileCommands.cs │ │ └── TextFileInfo.cs │ ├── Tools │ │ └── Shell │ │ │ ├── ModuleSettings.cs │ │ │ └── ToolsShellCommands.cs │ └── UnitTestsCommands.cs ├── LICENSE.md ├── ModuleInfo.cs ├── OrbitalShell-Kernel-Commands.csproj └── assets │ └── robotazteque.png ├── OrbitalShell-Kernel ├── .gitattributes ├── .gitignore ├── Component │ ├── CommandLine │ │ ├── Batch │ │ │ ├── CommandBatchProcessor.cs │ │ │ └── ICommandBatchProcessor.cs │ │ ├── CommandModel │ │ │ ├── CommandAliasAttribute.cs │ │ │ ├── CommandAttribute.cs │ │ │ ├── CommandNameAttribute.cs │ │ │ ├── CommandNamespaceAttribute.cs │ │ │ ├── CommandParameterSpecification.cs │ │ │ ├── CommandSpecification.cs │ │ │ ├── CommandsAttribute.cs │ │ │ ├── CommandsNamespaceAttribute.cs │ │ │ ├── CustomParameterType.cs │ │ │ ├── ICommandsDeclaringType.cs │ │ │ ├── OptionAttribute.cs │ │ │ ├── OptionRequireParameterAttribute.cs │ │ │ ├── ParameterAttribute.cs │ │ │ └── RequireOSCommandAttribute.cs │ │ ├── Parsing │ │ │ ├── AmbiguousParameterSpecificationException.cs │ │ │ ├── CommandLineParser.cs │ │ │ ├── CommandLineSyntax.cs │ │ │ ├── CommandSyntax.cs │ │ │ ├── CommandSyntaxParsingResult.cs │ │ │ ├── ExternalParserExtensionContext.cs │ │ │ ├── IExternalParserExtension.cs │ │ │ ├── IMatchingParameter.cs │ │ │ ├── ISyntaxAnalyser.cs │ │ │ ├── MatchingParameter.cs │ │ │ ├── MatchingParameters.cs │ │ │ ├── ParameterSyntax.cs │ │ │ ├── ParseError.cs │ │ │ ├── ParseErrorException.cs │ │ │ ├── ParseResult.cs │ │ │ ├── ParseResultType.cs │ │ │ ├── PipelineParseResult.cs │ │ │ ├── PipelineParseResults.cs │ │ │ ├── SyntaxAnalyser.cs │ │ │ └── ValueTextParser.cs │ │ ├── Pipeline │ │ │ ├── PipelineCondition.cs │ │ │ ├── PipelineParser.cs │ │ │ ├── PipelineProcessor.cs │ │ │ └── PipelineWorkUnit.cs │ │ ├── Processor │ │ │ ├── CommandEvaluationContext.cs │ │ │ ├── CommandEvaluationContextSettings.cs │ │ │ ├── CommandLineProcessor.cs │ │ │ ├── CommandLineProcessorCommands.cs │ │ │ ├── CommandLineProcessorExternalParserExtension.cs │ │ │ ├── CommandLineProcessorSettings.cs │ │ │ ├── CommandResult.cs │ │ │ ├── ExpressionEvaluationResult.cs │ │ │ ├── ICommandLineProcessor.cs │ │ │ ├── ICommandLineProcessorSettings.cs │ │ │ ├── ICommandResult.cs │ │ │ └── ReturnCode.cs │ │ └── Reader │ │ │ ├── BeginReadlnAsyncResult.cs │ │ │ ├── CommandLineReader.cs │ │ │ ├── ExpressionEvaluationResultCommandDelegate.cs │ │ │ ├── ICommandLineReader.cs │ │ │ └── Interaction.cs │ ├── Console │ │ ├── EchoEvaluationContext.cs │ │ ├── EchoPrimitiveMap.cs │ │ ├── EchoPrimitives.cs │ │ ├── FormatingOptions.cs │ │ ├── IShellObject.cs │ │ ├── ShellConsoleTextWriterWrapper.cs │ │ ├── ShellObject.cs │ │ └── TableFormattingOptions.cs │ ├── Logger.cs │ └── Shell │ │ ├── CommandNamespace.cs │ │ ├── CommandsAlias.cs │ │ ├── CommandsHistory.cs │ │ ├── Data │ │ ├── DataObject.cs │ │ ├── DataRegistry.cs │ │ ├── DataValue.cs │ │ ├── IDataObject.cs │ │ └── Table.cs │ │ ├── Defaults │ │ ├── .aliases │ │ ├── .init │ │ └── .profile │ │ ├── Hook │ │ ├── AggregateHookResult.cs │ │ ├── HookAttribute.cs │ │ ├── HookManager.cs │ │ ├── HookSpecification.cs │ │ ├── HookTriggerMode.cs │ │ ├── Hooks.cs │ │ ├── HooksAttribute.cs │ │ └── IHookManager.cs │ │ ├── ICommandsAlias.cs │ │ ├── Init │ │ ├── IShellArgsOptionBuilder.cs │ │ ├── IShellBootstrap.cs │ │ ├── IShellServiceHost.cs │ │ ├── ShellArg.cs │ │ ├── ShellArgValue.cs │ │ ├── ShellArgsOptionBuilder.cs │ │ ├── ShellBootstrap.cs │ │ ├── ShellServiceHost.cs │ │ └── ShellServicesInitializer.cs │ │ ├── Module │ │ ├── Data │ │ │ ├── ModuleInit.cs │ │ │ ├── ModuleInitItem.cs │ │ │ ├── ModuleList.cs │ │ │ └── ModuleReference.cs │ │ ├── IModuleCommandManager.cs │ │ ├── IModuleManager.cs │ │ ├── ModuleAuthorsAttribute.cs │ │ ├── ModuleCommandManager.cs │ │ ├── ModuleDependencyAttribute.cs │ │ ├── ModuleInfo.cs │ │ ├── ModuleManager.cs │ │ ├── ModuleSet.cs │ │ ├── ModuleShellMinVersionAttribute.cs │ │ ├── ModuleSpecification.cs │ │ ├── ModuleTargetPlateformAttribute.cs │ │ ├── ModuleUtil.cs │ │ ├── ModuleVersion.cs │ │ ├── ShellModuleAttribute.cs │ │ └── modules-init.json │ │ └── Variable │ │ ├── ShellEnvironment.cs │ │ ├── ShellEnvironmentNamespace.cs │ │ ├── ShellEnvironmentVar.cs │ │ ├── VariableNamespace.cs │ │ ├── VariableSyntax.cs │ │ └── Variables.cs ├── LICENSE.md ├── Lib │ ├── Data │ │ ├── FindCounts.cs │ │ ├── PatternString.cs │ │ └── VersionNumber.cs │ ├── DecoratorsInvokersTypesExt.cs │ ├── FileSystem │ │ ├── DirectoryPath.cs │ │ ├── Drives.cs │ │ ├── FilePath.cs │ │ ├── FileSystem.cs │ │ ├── FileSystemPath.cs │ │ ├── FileSystemPathFormattingOptions.cs │ │ └── WildcardFilePath.cs │ ├── Sys │ │ ├── IServiceProviderScope.cs │ │ ├── ServiceProviderScope.cs │ │ ├── StringWrapper.cs │ │ └── TypeBuilder.cs │ └── TypesExt.cs ├── ModuleInfo.cs ├── Modules │ └── read-me.txt ├── OrbitalShell-Kernel.csproj └── assets │ └── robotazteque.png ├── OrbitalShell-UnitTests ├── .gitattributes ├── .gitignore ├── BaseTests.cs ├── CommandLineProcessorTests.cs ├── CommandLineSyntaxParserTests.cs ├── LICENSE.md ├── OrbitalShell-UnitTests.csproj ├── README.md └── assets │ ├── robotazteque.ico │ └── robotazteque.png ├── OrbitalShell-WebAPI ├── Controllers │ ├── ShellController.cs │ └── WeatherForecastController.cs ├── Models │ ├── ShellExecResult.cs │ └── WeatherForecast.cs ├── OrbitalShell-WebAPI.csproj ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json └── appsettings.json ├── OrbitalShell.sln ├── README.md ├── assets ├── 2021-02-12 03_47_28-Window.png ├── 2021-02-12 14_28_35-Window.png ├── orbital-shell.png ├── pegi46small.png ├── robotazteque.png ├── shell-wt-1.0.8-2.png └── tra4brains.png ├── deploy ├── docker │ ├── Dockerfile-ubuntu-latest │ ├── Dockerfile-windows-latest │ └── readme.md └── installer │ └── linux │ ├── orbsh_installer.sh │ └── readme.md ├── docs ├── README.md └── _config.yml └── module-index-repository ├── module-list.json └── readme.txt /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET Build & Test 2 | 3 | on: 4 | push: 5 | branches: [ master, dev ] 6 | 7 | pull_request: 8 | branches: [ master, dev ] 9 | types: [opened, synchronize, closed] 10 | 11 | jobs: 12 | build_test: 13 | 14 | strategy: 15 | matrix: 16 | os: [ 'ubuntu-latest', 'windows-latest', 'macOs-latest' ] 17 | dotnet-version: [ '5.0' ] 18 | 19 | runs-on: ${{ matrix.os }} 20 | 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v2 24 | 25 | - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} 26 | uses: actions/setup-dotnet@v1 27 | with: 28 | dotnet-version: ${{ matrix.dotnet-version }} 29 | 30 | - name: Clean Project 31 | run: dotnet clean --configuration Release && dotnet nuget locals all --clear 32 | 33 | - name: Install dependencies 34 | run: dotnet restore 35 | 36 | - name: Build Project 37 | run: dotnet build --no-restore 38 | 39 | - name: Test Project 40 | run: dotnet test --no-build --verbosity normal 41 | 42 | - name: Store Artifact 43 | uses: actions/upload-artifact@main 44 | with: 45 | name: Orbital Shell artifacts - ${{ matrix.os }} 46 | path: ./OrbitalShell-CLI/bin/Debug/net5.0/ 47 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request, issues] 4 | 5 | jobs: 6 | greeting: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/first-interaction@v1 10 | with: 11 | repo-token: ${{ secrets.GITHUB_TOKEN }} 12 | issue-message: 'Message: Users first issue' 13 | pr-message: 'Message: User first pull request' 14 | -------------------------------------------------------------------------------- /.github/workflows/publish-dockerhub.yml: -------------------------------------------------------------------------------- 1 | name: Publish on Docker Hub 2 | 3 | on: 4 | workflow_run: 5 | workflows: [ '.NET Build & Test' ] 6 | branches: [ master ] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | publish: 12 | runs-on: ${{ matrix.os }} 13 | 14 | strategy: 15 | matrix: 16 | os: [ 'ubuntu-latest' ] 17 | 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v2 21 | 22 | - name: Download artifact 23 | uses: dawidd6/action-download-artifact@v2 24 | with: 25 | github_token: ${{ secrets.GITHUB_TOKEN }} 26 | workflow: dotnet.yml 27 | workflow_conclusion: success 28 | branch: master 29 | name: Orbital Shell artifacts - ${{ matrix.os }} 30 | path: ./OrbitalShell-CLI/bin/Debug/net5.0/ 31 | repo: ${{ github.repository }} 32 | 33 | - name: Login to Docker Hub 34 | uses: docker/login-action@v1 35 | with: 36 | username: ${{ secrets.DOCKER_USERNAME }} 37 | password: ${{ secrets.DOCKER_PASSWORD }} 38 | 39 | - name: Build and push to Docker Hub 40 | uses: docker/build-push-action@v2 41 | with: 42 | context: . 43 | file: deploy/docker/Dockerfile-${{ matrix.os }} 44 | push: true 45 | tags: orbitalshell/orbital-shell:${{ matrix.os }} 46 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | //"itmcdev.dotnet-csharp-extension-pack", 4 | //"salbert.awesome-dotnetcore-pack" 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | // ,"-env:Settings.EnableConsoleBackgroundTransparentMode=true" 14 | "program": "${workspaceFolder}/OrbitalShell-CLI/bin/Debug/netcoreapp3.1/orbsh.dll", 15 | "args": ["--env:settings.console.enableCompatibilityMode=true"], 16 | "cwd": "${workspaceFolder}", 17 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 18 | "console": "integratedTerminal", 19 | "stopAtEntry": false 20 | }, 21 | { 22 | "name": ".NET Core Attach", 23 | "type": "coreclr", 24 | "request": "attach", 25 | "processId": "${command:pickProcess}" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | //"workbench.settings.editor": "json", 3 | "shellLauncher.shells.windows": [ 4 | { 5 | //"shell": "C:\\Users\\franc\\Documents\\Visual Studio 2019\\Projects\\Applications\\dotnet-console-app-toolkit\\OrbitalShell\\OrbitalShell-CLI\\bin\\Debug\\netcoreapp3.1\\orbsh.exe", 6 | "shell": "orbsh.exe", 7 | // ,"-env:Settings.EnableConsoleBackgroundTransparentMode=true" 8 | "args": ["--env:settings.console.enableCompatibilityMode=true"], 9 | "label": "Orbital Shell" 10 | }, 11 | { 12 | "shell": "C:\\Windows\\System32\\cmd.exe", 13 | "label": "cmd" 14 | }, 15 | { 16 | "shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 17 | "label": "PowerShell" 18 | }, 19 | { 20 | "shell": "C:\\Program Files\\Git\\bin\\bash.exe", 21 | "label": "Git bash" 22 | }, 23 | { 24 | "shell": "C:\\Windows\\System32\\bash.exe", 25 | "label": "WSL Bash" 26 | } 27 | ], 28 | 29 | "explorer.confirmDelete": false, 30 | "python.pythonPath": "C:\\Users\\franc\\AppData\\Local\\Programs\\Python\\Python39\\python.exe", 31 | "todo-tree.tree.showScanModeButton": false, 32 | "workbench.iconTheme": "vscode-icons", 33 | "editor.suggestSelection": "first", 34 | /*"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", 35 | "editor.formatOnPaste": false, 36 | "editor.formatOnSave": false, 37 | "editor.formatOnType": false,*/ 38 | "window.zoomLevel": 0, 39 | "terminal.external.windowsExec": "C:\\Users\\franc\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe", 40 | //"terminal.explorerKind": "external", 41 | "terminal.integrated.shell.windows": "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 42 | "terminal.integrated.copyOnSelection": true, 43 | "terminal.integrated.cursorBlinking": true, 44 | "terminal.integrated.detectLocale": "on", 45 | "terminal.integrated.environmentChangesIndicator": "on", 46 | "terminal.integrated.localEchoLatencyThreshold": 0, 47 | "terminal.integrated.shellArgs.windows": "", 48 | //"terminal.integrated.rendererType": "canvas", 49 | "debug.onTaskErrors": "showErrors", 50 | "csharp.semanticHighlighting.enabled": true, 51 | "omnisharp.enableImportCompletion": true, 52 | "editor.quickSuggestions": true, 53 | "editor.suggestOnTriggerCharacters": true, 54 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | //"${workspaceFolder}/OrbitalShell/OrbitalShell.csproj", 11 | "${workspaceFolder}/OrbitalShell.sln", 12 | "/property:GenerateFullPaths=true", 13 | "/consoleloggerparameters:NoSummary" 14 | ], 15 | "problemMatcher": "$msCompile" 16 | }, 17 | { 18 | "label": "publish", 19 | "command": "dotnet", 20 | "type": "process", 21 | "args": [ 22 | "publish", 23 | //"${workspaceFolder}/OrbitalShell/OrbitalShell.csproj", 24 | "${workspaceFolder}/OrbitalShell.sln", 25 | "/property:GenerateFullPaths=true", 26 | "/consoleloggerparameters:NoSummary" 27 | ], 28 | "problemMatcher": "$msCompile" 29 | }, 30 | { 31 | "label": "watch", 32 | "command": "dotnet", 33 | "type": "process", 34 | "args": [ 35 | "watch", 36 | "run", 37 | //"${workspaceFolder}/OrbitalShell/OrbitalShell.csproj", 38 | "${workspaceFolder}/OrbitalShell.sln", 39 | "/property:GenerateFullPaths=true", 40 | "/consoleloggerparameters:NoSummary" 41 | ], 42 | "problemMatcher": "$msCompile" 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guildelines 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Franck Gaspoz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/orbsh.dll", 13 | "args": ["-env:Orbsh.Settings.EnableFixLowANSITerminals=true"], 14 | "cwd": "${workspaceFolder}", 15 | "console": "integratedTerminal", 16 | "stopAtEntry": false, 17 | "externalConsole": true 18 | }, 19 | { 20 | "name": ".NET Core Attach", 21 | "type": "coreclr", 22 | "request": "attach", 23 | "processId": "${command:pickProcess}" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /OrbitalShell-CLI/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "terminal.integrated.shell.windows": "", 3 | "terminal.external.windowsExec": "C:\\Users\\franc\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe", 4 | } -------------------------------------------------------------------------------- /OrbitalShell-CLI/Component/CommandLine/Processor/CommandLineProcessorSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Processor 4 | { 5 | public class OrbitalShellCommandLineProcessorSettings : CommandLineProcessorSettings 6 | { 7 | public OrbitalShellCommandLineProcessorSettings() 8 | { 9 | AppName = "orbsh"; 10 | AppLongName = "Orbital Shell"; 11 | AppEditor = "released on June 2020 under licence MIT"; 12 | AppVersion = Assembly.GetExecutingAssembly().GetCustomAttribute().Version; 13 | 14 | AppDataFolderName = "OrbitalShell"; 15 | UserProfileFileName = ".profile"; 16 | InitFileName = ".init"; 17 | LogFileName = ".log"; 18 | HistoryFileName = ".history"; 19 | CommandsAliasFileName = ".aliases"; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/Component/Shell/Defaults/.profile: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # --------------------------------------------------------------------------------------------------------- 3 | # this is the default orbsh user profile init script 4 | # --------------------------------------------------------------------------------------------------------- 5 | 6 | # set the prompt 7 | 8 | #prompt "(RSTXTA)(b8=19) (b8=20) (exec=System.Environment.CurrentDirectory) (b8=19,f8=46) (b8=18) (b8=17) (br)(f=yellow) > (rdc)" 9 | #prompt "(RSTXTA)(f=cyan)(uon)(exec=System.Environment.CurrentDirectory)(tdoff)(br) (f=yellow,b=darkblue)>(rdc) " 10 | prompt "(RSTXTA)(f=green)(uon)(exec=[[OrbitalShell.Lib.FileSystem.FileSystemPath.UnescapePathSeparators(System.Environment.CurrentDirectory)]])(tdoff)(br)(f=black,b=green)>(rdc) " 11 | #prompt "(RSTXTA)(b8=19) (b8=20) $USERDOMAIN (b8=19,f8=46) (b8=18,f=yellow)>(b8=17) (rdc)" 12 | #prompt "(RSTXTA)(f=cyan)$USERDOMAIN (f=white)> (rdc)" 13 | #prompt "(RSTXTA) > " 14 | 15 | # samples 16 | 17 | #echo "(b8=196) (b8=202) (b8=208) (b8=214) (b8=220) (b8=226) (b8=190) (b8=154) (b8=118) (b8=82) (b8=46) (b8=41) (b8=36) (b8=31) (b8=26) (b8=21) (b8=20) (b8=19) (b8=54) (b8=90) (b8=126) (b8=162) (b8=198) (b8=204)" 18 | 19 | # dev aliases 20 | 21 | alias proj "cd '$shell/../../../..'" 22 | alias vsproj "cd \"$home/documents/visual studio 2019/projects/applications\"" 23 | 24 | # git aliases 25 | 26 | alias gss "git status -s -b -u -M --porcelain" 27 | alias gs "git status" 28 | alias ga "git add . && git status" 29 | 30 | # modules aliases 31 | 32 | alias mf "find $modules --top --fullname --dir" 33 | 34 | # command aliases 35 | 36 | alias dirs "dir -r -d" 37 | 38 | # add usefull variables to shell environment 39 | 40 | set scripts $shell/scripts 41 | 42 | # advice(s) 43 | 44 | echo "TIP: try module -f to list available modules, module -i {moduleId} to install a module in the shell, module -u {moduleId} to update an installed module, module --update-all [--check-only] to check/update all modules" 45 | echo "" 46 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/Component/Shell/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // map shell environment variables and namespaces 3 | 4 | "env": { 5 | 6 | "debug": { 7 | 8 | "enableHookTrace": false, 9 | "enablePipelineTrace": false 10 | 11 | }, 12 | 13 | "settings": { 14 | 15 | "clp": { 16 | 17 | "enableShellExecTraceProcessStart": false, 18 | "enableShellExecTraceProcessEnd": false, 19 | "shellExecBatchExt": ".sh" 20 | 21 | }, 22 | 23 | "clr": { 24 | 25 | "comPreAnalysisOutput": "\r\n", 26 | "comPostExecOutModifiedOutput": "\r\n", 27 | "comPostExecOutput": "" 28 | 29 | }, 30 | 31 | "console": { 32 | 33 | "prompt": "> ", 34 | "initialWindowWidth": -1, 35 | "initialWindowHeight": -1, 36 | "enableCompatibilityMode": false, 37 | "enableAvoidEndOfLineFilledWithBackgroundColor": true, 38 | 39 | "banner": { 40 | 41 | "path": "./Commands/CommandLineProcessor/banner-4.txt", 42 | "isEnabled": true, 43 | "startColorIndex": 21, 44 | "startColorIndex2": 49, 45 | "colorIndexStep": 6 46 | } 47 | 48 | }, 49 | 50 | "module": { 51 | 52 | "providerUrls": [ 53 | "https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/master/module-index-repository/module-list.json", 54 | "https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/dev/module-index-repository/module-list.json" 55 | ] 56 | 57 | } 58 | 59 | }, 60 | 61 | "display": { 62 | 63 | } 64 | }, 65 | 66 | "local": { 67 | 68 | }, 69 | 70 | "global": { 71 | 72 | }, 73 | 74 | "_": { 75 | 76 | } 77 | } -------------------------------------------------------------------------------- /OrbitalShell-CLI/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) June 2020 franck gaspoz (franck.gaspoz@gmail.com) 2 | Licence Free MIT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the « Software »), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED « AS IS », WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------------------------------ 23 | 24 | Copyright (c) Juin 2020 franck gaspoz (franck.gaspoz@gmail.com) 25 | Licence Libre MIT 26 | 27 | L’autorisation est accordée, gracieusement, à toute personne acquérant une copie 28 | de ce logiciel et des fichiers de documentation associés (le « logiciel »), de commercialiser 29 | le logiciel sans restriction, notamment les droits d’utiliser, de copier, de modifier, 30 | de fusionner, de publier, de distribuer, de sous-licencier et / ou de vendre des copies du logiciel, 31 | ainsi que d’autoriser les personnes auxquelles la logiciel est fournie à le faire, 32 | sous réserve des conditions suivantes : 33 | 34 | La déclaration de copyright ci-dessus et la présente autorisation doivent être incluses dans 35 | toutes copies ou parties substantielles du logiciel. 36 | 37 | LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D’AUCUNE SORTE, EXPLICITE OU IMPLICITE, 38 | NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D’ADÉQUATION À UN USAGE PARTICULIER ET D’ABSENCE 39 | DE CONTREFAÇON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D’AUTEUR NE SERONT RESPONSABLES 40 | DE TOUT DOMMAGE, RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D’UN CONTRAT, 41 | D’UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE LOGICIEL OU SON UTILISATION, 42 | OU AVEC D’AUTRES ÉLÉMENTS DU LOGICIEL. -------------------------------------------------------------------------------- /OrbitalShell-CLI/Program.cs: -------------------------------------------------------------------------------- 1 |  2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | using OrbitalShell.Component.CommandLine.Processor; 6 | using OrbitalShell.Component.Shell.Init; 7 | 8 | namespace OrbitalShell 9 | { 10 | public static class Program 11 | { 12 | static int Main(string[] args) 13 | { 14 | var returnCode = 15 | GetShellServiceHost(args) 16 | .RunShellServiceHost(args); 17 | 18 | App.Host.Run(); 19 | 20 | return returnCode; 21 | } 22 | 23 | public static IShellServiceHost GetShellServiceHost(string[] args) 24 | => ShellServiceHost.GetShellServiceHost( 25 | args, 26 | (hostBuilder) => 27 | hostBuilder.ConfigureServices( 28 | (_, services) => 29 | services.AddScoped 30 | () 31 | ) 32 | ); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "OrbitalShell-CLI": { 4 | "commandName": "Project" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /OrbitalShell-CLI/README.md: -------------------------------------------------------------------------------- 1 | ## Orbital Shell 2 | 3 | | Orbital Shell is a multi-plateform (**windows, linux, macos, arm**) command shell (according to .Net Core supported platforms and APIs compatibilities), inspired by bash and **POSIX** recommendations.

It provides any usual bash shell feature (even if modernized) and 'user friendly' syntaxes allowing to access (get/set/call) C# objects.

Developed using **C# 8, .NET Core 3.1/Net 5 and .NET Standard 2.1** 4 | -- | -- 5 |                                             |   6 | 7 | This shell integrates the most usefull shell commands, and is intented to be extended by coding new commands or downloading new commands modules within a repository of modules. Of course it can be enterly customized by using the features integrated to the shell (scripts, functions, commands, aliases, settings, parametrization,...). Having a strong ANSI/VT-100-220-300-500 support, it provides structured and colorized display of data and information (support of ASCII, Unicode and 24 bits colors). 8 | 9 | ## About the project 10 | 11 | Find any information and documentation about this project on the project's Web Site @ [Orbital SHell Git-Pages](https://orbitalshell.github.io/Orbital-Shell/) 12 | 13 | Developers and users manuals are available in the project web site @ [Orbital SHell Git-Pages (documentation)](https://orbitalshell.github.io/Orbital-Shell/documentation) 14 | 15 | > [![licence mit](https://img.shields.io/badge/licence-MIT-blue.svg)](license) This project is licensed under the terms of the MIT license: [LICENSE](LICENSE) 16 | 17 | > project repositories status:
18 | ![orbital-shell](https://img.shields.io/badge/Orbital--Shell-repository-lightgrey?style=plastic) 19 | ![last commit](https://img.shields.io/github/last-commit/orbitalshell/Orbital-Shell?style=plastic) 20 | ![version](https://img.shields.io/github/v/tag/orbitalshell/Orbital-Shell?style=plastic) 21 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/assets/robotazteque.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-CLI/assets/robotazteque.ico -------------------------------------------------------------------------------- /OrbitalShell-CLI/assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-CLI/assets/robotazteque.png -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-linux-arm.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-linux-arm 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for linux-arm plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-linux-arm64.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-linux-arm64 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for linux-arm64 plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-linux-musl-x64.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-linux-musl-x64 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for linux-musl-x64 plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-linux-x64.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-linux-x64 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for linux-x64 plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-osx-x64.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-osx-x64 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for osx-x64 plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell-win-x64.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell-win-x64 6 | $version$ 7 | Franck Gaspoz 8 | Franck Gaspoz 9 | false 10 | MIT 11 | 12 | https://orbitalshell.github.io/Orbital-Shell/ 13 | 14 | 15 | assets/robotazteque.png 16 | 17 | This is the Orbital Shell CLI binaries of self-contained app for win-x64 plateform. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 18 | initial stable release of binaries 19 | © Orbital Shell 2020 20 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/build/OrbitalShell.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OrbitalShell 6 | 7 | $version$ 8 | Franck Gaspoz 9 | Franck Gaspoz 10 | false 11 | MIT 12 | 13 | https://orbitalshell.github.io/Orbital-Shell/ 14 | 15 | 16 | assets/robotazteque.png 17 | 18 | This is the Orbital Shell CLI binaries for any plateform having dotnet netcore3.1 installed. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core. 19 | initial stable release of binaries 20 | © Orbital Shell 2020 21 | prompt git git-branch git-status bash linux shell interactive csharp netcore5 netstandard21 netcore31 cli command-line-tool command-line-parser command-line-interface 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/com-dev-notes.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # commands - notes 3 | # ------------------------------------------------------------------------------------------------ 4 | 5 | # list orbital shell nupkg packages files (after nuget install) 6 | # ------------------------------------------------------------- 7 | 8 | cd $modules 9 | nuget install orbitalshell -Prerelease 10 | find . -p "*Orbital*lib*" -f -s 11 | find . -p "*contentFiles*" -f -s 12 | 13 | # nuget 14 | # ----- 15 | 16 | nuget spec OrbitalShell.csproj 17 | nuget pack OrbitalShell.nuspec 18 | nuget sources Add -Name githuborbsh -Source https://nuget.pkg.github.com/OrbitalShell/index.json 19 | 20 | # github 21 | # ------ 22 | 23 | ssh-keygen -t rsa -b 4096 24 | 25 | # publid OrbitalShell-cli 26 | # -------------------------------------------------------------- 27 | 28 | cd OrbitalShell-cli 29 | # framework-dependent 30 | dotnet publish --configuration Release --output bin/publish/netcoreapp3.1/ 31 | # framework-independent (self-contained) 32 | dotnet publish --runtime win-x64 --configuration Release --output bin/publish/win-x64/ 33 | dotnet publish --runtime linux-x64 --configuration Release --output bin/publish/linux-x64/ 34 | dotnet publish --runtime linux-musl-x64 --configuration Release --output bin/publish/linux-musl-x64/ 35 | dotnet publish --runtime linux-arm --configuration Release --output bin/publish/linux-arm/ 36 | dotnet publish --runtime linux-arm64 --configuration Release --output bin/publish/linux-arm64/ 37 | dotnet publish --runtime osx-x64 --configuration Release --output bin/publish/osx-x64/ 38 | 39 | which dotnet 40 | cd "C:/Program Files/dotnet/dotnet.exe" 41 | 42 | # get nuget binaries (.netcore 3.1 assemblies) 43 | # -------------------------------------------------------------- 44 | 45 | # framework-dependent 46 | nuget install orbitalshell 47 | # framework-independent (self-contained) 48 | nuget install orbitalshell-win-x64 49 | nuget install orbitalshell-linux-x64 50 | nuget install orbitalshell-linux-musl-x64 51 | nuget install orbitalshell-linux-arm 52 | nuget install orbitalshell-linux-arm64 53 | nuget install orbitalshell-osx-x64 54 | # then cd OrbitalShell-{rid}.{ver}/{rid}/ 55 | 56 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/commands.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # commands samples 3 | 4 | echo "(b8=196) (b8=202) (b8=208) (b8=214) (b8=220) (b8=226) (b8=190) (b8=154) (b8=118) (b8=82) (b8=46) (b8=41) (b8=36) (b8=31) (b8=26) (b8=21) (b8=20) (b8=19) (b8=54) (b8=90) (b8=126) (b8=162) (b8=198) (b8=204)" 5 | 6 | cd $APPDATA/OrbitalShell 7 | dir Component/CommandLine/Defaults 8 | more Component/CommandLine/Defaults/.profile 9 | more $APPDATA/OrbitalShell/.profile 10 | echo $Env.Orbsh.Display.Colors.ColorSettings.Dark -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/echo-directives-test.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------ 2 | tests of echo directives 3 | ------------------------------------------------ 4 | 5 | (f=cyan,b=darkcyan)test: list of directives(rdc) 6 | 7 | begin text|(f=cyan,b=darkblue)test: begin with a text and having directives(rdc) 8 | (fr=cyanure)test: unknown directive name(rdc) 9 | (f=cyanure)(f=darkyellow)test: bad directive value(rdc) ERROR 2 10 | (f=red,f=cyanure)(f=darkyellow)test 1: bad directive name at pos>0 in list(rdc) ERROR 1 11 | (f=yellow,fr=cyanure)test 1: unknown directive value at pos>0 in list(rdc) 12 | (f=cyan)unique directive(f=white) 13 | 14 | (f=cyan)set foreground(f=white) 15 | (b=darkblue)set background(b=black) 16 | 17 | ------------------------------------ 18 | 19 | (invon)inverted(tdoff) 20 | (uon)underline(tdoff) 21 | 22 | (f=darkblue)darkblue 23 | (f=darkgreen)darkgreen 24 | (f=darkcyan)darkcyan 25 | (f=darkred)darkred 26 | (f=darkmagenta)darkmagenta 27 | (f=darkyellow)darkyellow 28 | (f=gray)gray 29 | (f=darkgray)darkgray 30 | (f=blue)blue 31 | (f=green)green 32 | (f=cyan)cyan 33 | (f=red)red 34 | (f=magenta)magenta 35 | (f=yellow)yellow 36 | (f=white)white 37 | 38 | (b=darkblue)darkblue 39 | (b=darkgreen)darkgreen 40 | (b=darkcyan)darkcyan 41 | (b=darkred)darkred 42 | (b=darkmagenta)darkmagenta 43 | (b=darkyellow)darkyellow 44 | (b=gray)gray 45 | (b=darkgray)darkgray 46 | (b=blue)blue 47 | (b=green)green 48 | (b=cyan)cyan 49 | (b=red)red 50 | (b=magenta)magenta 51 | (b=yellow)yellow 52 | (b=white,f=black)white 53 | 54 | ------------------------------------ 55 | 56 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/prompt-samples.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | prompt "(b8=16) (b8=17) (b8=18) (b8=19) (b8=20) (b8=21,f8=46)>(b8=20)(b8=19) (rdc)" 3 | prompt "(b8=16,f8=87) (b8=17) (b8=18) (b8=19) (b8=20) (b8=21,f8=46)orbsh >(b8=20)(b8=19) (rdc)" 4 | prompt "(b8=16) (b8=17) (b8=18) (b8=19) (b8=20) (b8=21,f8=46)(exec=[[System.DateTime.Now]]) >(b8=20)(b8=19) (rdc)" 5 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/publish-cli-release.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # build/public cli .net 5 release 3 | proj 4 | #cd OrbitalShell-CLI 5 | dotnet publish --configuration Release --output bin/publish/net5.0/ 6 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/publish-kernel-packages.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # build/publish orbital shell kernel packages 3 | 4 | set version 1.0.9.nupkg 5 | 6 | cls 7 | echo "(b=darkgreen,f=black) " 8 | echo "(b=darkgreen,f=black) build/publish orbital shell kernel packages (rdc)" 9 | echo "(b=darkgreen,f=black) " 10 | echo 11 | proj 12 | #dotnet build OrbitalShell.sln -c Release 13 | 14 | #nuget-push OrbitalShell-ConsoleApp/bin/Debug/OrbitalShell-ConsoleApp.$version $key 15 | #nuget-push OrbitalShell-Kernel/bin/Debug/OrbitalShell-Kernel.$version $key 16 | #nuget-push OrbitalShell-Kernel-Commands/bin/Debug/OrbitalShell-Kernel-Commands.$version $key 17 | 18 | nuget-push OrbitalShell-ConsoleApp/bin/Release/OrbitalShell-ConsoleApp.$version $key 19 | nuget-push OrbitalShell-Kernel/bin/Release/OrbitalShell-Kernel.$version $key 20 | nuget-push OrbitalShell-Kernel-Commands/bin/Release/OrbitalShell-Kernel-Commands.$version $key 21 | 22 | echo "(b=darkgreen,f=yellow) Done. (rdc)" 23 | -------------------------------------------------------------------------------- /OrbitalShell-CLI/scripts/unicode-boxes.sh: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # draw boxes using unicodes characters (fgz - 19/1/11) 3 | echo "(EdgeTopLeft,EdgeTopRight)1 (2 lines box)(br)(EdgeBottomLeft,EdgeBottomRight)2" 4 | echo "(EdgeTopLeft,BarHorizontal,BarHorizontal,BarHorizontal,EdgeTopRight)1 (3 lines box)(br)(BarVertical) ? (BarVertical)2(br)(EdgeBottomLeft,BarHorizontal,BarHorizontal,BarHorizontal,EdgeBottomRight)3" 5 | 6 | echo "(EdgeTopLeft,EdgeTopRight)(br)(EdgeBottomLeft,EdgeBottomRight)" 7 | echo "(EdgeTopLeft,BarHorizontal,BarHorizontal,BarHorizontal,EdgeTopRight)(br)(BarVertical) ? (BarVertical)(br)(EdgeBottomLeft,BarHorizontal,BarHorizontal,BarHorizontal,EdgeBottomRight)" 8 | 9 | echo "(EdgeDoubleTopLeft,EdgeDoubleTopRight)1 (2 lines box)(br)(EdgeDoubleBottomLeft,EdgeDoubleBottomRight)2" 10 | echo "(EdgeDoubleTopLeft,BarDoubleHorizontal,BarDoubleHorizontal,BarDoubleHorizontal,EdgeDoubleTopRight)1 (3 lines box)(br)(BarDoubleVertical) ? (BarDoubleVertical)2(br)(EdgeDoubleBottomLeft,BarDoubleHorizontal,BarDoubleHorizontal,BarDoubleHorizontal,EdgeDoubleBottomRight)3" 11 | 12 | echo "(EdgeDoubleTopLeft,EdgeDoubleTopRight)(br)(EdgeDoubleBottomLeft,EdgeDoubleBottomRight)" 13 | echo "(EdgeDoubleTopLeft,BarDoubleHorizontal,BarDoubleHorizontal,BarDoubleHorizontal,EdgeDoubleTopRight)(br)(BarDoubleVertical) ? (BarDoubleVertical)(br)(EdgeDoubleBottomLeft,BarDoubleHorizontal,BarDoubleHorizontal,BarDoubleHorizontal,EdgeDoubleBottomRight)" 14 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/App.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Hosting; 3 | using hosting = Microsoft.Extensions.Hosting; 4 | 5 | using OrbitalShell.Component.Console; 6 | using System; 7 | 8 | namespace OrbitalShell 9 | { 10 | 11 | /// 12 | /// console app bootstrap 13 | /// 14 | /// 15 | /// begin DI init 16 | /// 17 | public static class App 18 | { 19 | public static IHostBuilder HostBuilder { get; private set; } 20 | 21 | public static IHost Host { get; private set; } 22 | 23 | public static IServiceProvider ServiceProvider => Host.Services ?? throw new Exception("host is not initialized"); 24 | 25 | public static IHostBuilder InitializeServices(string[] args = null) 26 | { 27 | args ??= Array.Empty(); 28 | HostBuilder = 29 | hosting.Host 30 | .CreateDefaultBuilder(args) 31 | .ConfigureServices((_, services) => 32 | services.AddSingleton()); 33 | return HostBuilder; 34 | } 35 | 36 | public static void EndInitializeServices() 37 | { 38 | Host = HostBuilder.Build(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/ActualWorkArea.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Console 2 | { 3 | public class ActualWorkArea 4 | { 5 | public readonly string Id; 6 | public readonly int Left; 7 | public readonly int Top; 8 | public readonly int Right; 9 | public readonly int Bottom; 10 | 11 | public ActualWorkArea(string id,int left,int top,int right,int bottom) 12 | { 13 | Id = id; 14 | Left = left; 15 | Right = right; 16 | Top = top; 17 | Bottom = bottom; 18 | } 19 | 20 | public void Deconstruct(out string id,out int left,out int top,out int right,out int bottom) 21 | { 22 | id = Id; 23 | left = Left; 24 | right = Right; 25 | top = Top; 26 | bottom = Bottom; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/BufferedOperationNotAvailableException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace OrbitalShell.Component.Console 6 | { 7 | public class BufferedOperationNotAvailableException : Exception 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/Color4BitMap.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Console 2 | { 3 | /// 4 | /// 4 bits colors map - see https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit 5 | /// 6 | public enum Color4BitMap 7 | { 8 | // 3 bits 9 | 10 | darkgray = 0b0, 11 | gray = 0b1111, 12 | red = 0b1, 13 | green = 0b10, 14 | yellow = 0b11, 15 | blue = 0b100, 16 | magenta = 0b101, 17 | cyan = 0b110, 18 | white = 0b111, 19 | 20 | // 4 bits 21 | 22 | black = 0b1000, 23 | darkred = 0b1001, 24 | darkgreen = 0b1010, 25 | darkyellow = 0b1011, 26 | darkblue = 0b1100, 27 | darkmagenta = 0b1101, 28 | darkcyan = 0b1110, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/EchoSequenceList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace OrbitalShell.Component.Console 6 | { 7 | public class EchoSequenceList : IEnumerable 8 | { 9 | public readonly List List 10 | = new List(); 11 | 12 | public void Add(EchoSequence printSequence) => List.Add(printSequence); 13 | 14 | public override string ToString() 15 | { 16 | var r = new StringBuilder(); 17 | foreach (var printSequence in List) 18 | r.AppendLine(printSequence.ToString()); 19 | return r.ToString(); 20 | } 21 | 22 | public string ToStringPattern() 23 | { 24 | var r = new StringBuilder(); 25 | foreach (var printSequence in List) 26 | r.Append(printSequence.ToStringPattern()); 27 | return r.ToString(); 28 | } 29 | 30 | public IEnumerator GetEnumerator() 31 | { 32 | return List.GetEnumerator(); 33 | } 34 | 35 | IEnumerator IEnumerable.GetEnumerator() 36 | { 37 | return List.GetEnumerator(); 38 | } 39 | 40 | public int TextLength 41 | { 42 | get 43 | { 44 | int n = 0; 45 | foreach (var seq in List) 46 | if (seq.IsText) n += seq.Length; 47 | return n; 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/InputMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | public class InputMap 6 | { 7 | public const int ExactMatch = 0; 8 | public const int NoMatch = -1; 9 | public const int PartialMatch = 1; 10 | 11 | public readonly string Text; 12 | public readonly object Code; 13 | /// 14 | /// -1 : no match, 0 : exact match , 1: partial match 15 | /// 16 | public readonly Func MatchInput; 17 | public readonly bool CaseSensitiveMatch; 18 | 19 | public InputMap(string text, bool caseSensitiveMatch = false) 20 | { 21 | Text = text; 22 | CaseSensitiveMatch = caseSensitiveMatch; 23 | } 24 | 25 | public InputMap(string text, object code,bool caseSensitiveMatch=false) 26 | { 27 | Text = text; 28 | Code = code; 29 | CaseSensitiveMatch = caseSensitiveMatch; 30 | } 31 | 32 | public InputMap(Func matchInput, object code) 33 | { 34 | MatchInput = matchInput; 35 | Code = code; 36 | } 37 | 38 | public int Match(string input,ConsoleKeyInfo key) 39 | { 40 | if (Text != null) { 41 | if (Text.Equals(input, CaseSensitiveMatch ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase)) return ExactMatch; 42 | if (Text.StartsWith(input, CaseSensitiveMatch ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase)) return PartialMatch; 43 | return NoMatch; 44 | } 45 | else return (MatchInput==null)?-1 : MatchInput(input,key); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/LineSplitList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | public class LineSplitList 6 | { 7 | public readonly List Splits; 8 | 9 | public readonly EchoSequenceList PrintSequences; 10 | 11 | public readonly int CursorIndex; 12 | 13 | public readonly int CursorLineIndex; 14 | 15 | public LineSplitList( 16 | List splits, 17 | EchoSequenceList printSequences, 18 | int cursorIndex=-1, 19 | int cursorLineIndex=-1) 20 | { 21 | Splits = splits; 22 | PrintSequences = printSequences; 23 | CursorIndex = cursorIndex; 24 | CursorLineIndex = cursorLineIndex; 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/StringSegment.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Lib; 2 | using System.Collections.Generic; 3 | 4 | namespace OrbitalShell.Component.Console 5 | { 6 | public class StringSegment 7 | { 8 | public string Text { get; protected set; } 9 | public int X { get; protected set; } 10 | public int Y { get; protected set; } 11 | public int Length { get; protected set; } 12 | 13 | public Dictionary Map; 14 | 15 | public void SetText(string text,bool updateCoords=false) 16 | { 17 | Text = text; 18 | if (updateCoords) 19 | { 20 | Length = text.Length; 21 | Y = X + Length; 22 | } 23 | } 24 | 25 | public StringSegment(string text, int x, int y, int length) 26 | { 27 | Text = text; 28 | X = x; 29 | Y = y; 30 | Length = length; 31 | } 32 | 33 | public StringSegment(string text, int x, int y) 34 | { 35 | Text = text; 36 | X = x; 37 | Y = y; 38 | Length = y - x + 1; 39 | } 40 | 41 | public StringSegment(string text, int x, int y, int length, Dictionary map) 42 | { 43 | Text = text; 44 | X = x; 45 | Y = y; 46 | Length = length; 47 | if (map != null && map.Count > 0) 48 | Map = new Dictionary { map }; 49 | } 50 | 51 | public StringSegment(string text, int x, int y, Dictionary map) 52 | { 53 | Text = text; 54 | X = x; 55 | Y = y; 56 | Length = y - x + 1; 57 | if (map != null && map.Count > 0) 58 | Map = new Dictionary { map }; 59 | } 60 | 61 | /// 62 | /// warn: this is intensively used in error messages... 63 | /// 64 | /// text representation of a StringSegment 65 | public override string ToString() 66 | { 67 | //return $"pos={X},{Y} l={Length} Text={Text}"; // warn: this is intensively used in error messages... 68 | return Text; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Console/WorkArea.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | public class WorkArea 6 | { 7 | public readonly string Id; 8 | public readonly Rectangle Rect = Rectangle.Empty; 9 | 10 | public WorkArea() { } 11 | 12 | public WorkArea(string id,int x,int y,int width,int height) 13 | { 14 | Id = id; 15 | Rect = new Rectangle(x, y, width, height); 16 | } 17 | 18 | public WorkArea(WorkArea workArea) 19 | { 20 | Id = workArea.Id; 21 | Rect = new Rectangle(workArea.Rect.X, workArea.Rect.Y, workArea.Rect.Width, workArea.Rect.Height); 22 | } 23 | 24 | public bool IsEmpty => Rect.IsEmpty; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/EchoDirective/CommandMap.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.EchoDirective 4 | { 5 | /// 6 | /// these map attribute a echo command delegate to an echo directive syntax 7 | /// 8 | public class CommandMap 9 | { 10 | public Dictionary Map = null; 11 | 12 | public CommandMap( Dictionary map) 13 | { 14 | Map = map; 15 | } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/ANSI/ANSIParser.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar; 3 | 4 | namespace OrbitalShell.Component.Parser.ANSI 5 | { 6 | public static class ANSIParser 7 | { 8 | #region attributes 9 | 10 | public const string GrammarFileName = "ansi-seq-patterns.txt"; 11 | 12 | static NonRecursiveFunctionGrammarParser _parser; 13 | 14 | #endregion 15 | 16 | #region init 17 | 18 | static ANSIParser() { 19 | var ap = System.Reflection.Assembly.GetExecutingAssembly().Location; 20 | var p = Path.Combine( Path.GetDirectoryName(ap),"Component","Parser","ANSI",GrammarFileName ); 21 | var lines = File.ReadLines(p); 22 | _parser = new NonRecursiveFunctionGrammarParser(lines); 23 | } 24 | 25 | #endregion 26 | 27 | public static SyntacticBlockList Parse(string s) => _parser.Parse(s); 28 | 29 | /// 30 | /// get the real length of the text without ansi sequences non printed characters 31 | /// 32 | /// text to be analyzed 33 | /// length of visible part of the text 34 | public static int GetTextLength(string s) => GetText(s).Length; 35 | 36 | /// 37 | /// gets the text part of the syntactic elements 38 | /// 39 | /// text to be analyzed 40 | /// string without ansi sequences 41 | public static string GetText(string s) => _parser.Parse(s).GetText(); 42 | 43 | /// 44 | /// indicates wether or not a string starts with a known ansi sequence. the parsed syntax is assigned in the out parameter 'syntax' 45 | /// 46 | /// text to be parsed 47 | /// parsed syntax 48 | /// true if the given text starts with a known ansi sequence. 49 | public static bool StartsWithANSISequence(string s,out SyntacticBlockList syntax) { 50 | syntax = _parser.Parse(s); 51 | if (syntax.Count==0) return false; 52 | return syntax[0].IsANSISequence; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/NonRecursiveFunctionalGrammar/Rule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | namespace OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar 6 | { 7 | public class Rule : List { 8 | static int _counter = 0; 9 | static object _counterLock = new object(); 10 | public int ID; 11 | 12 | public TreePath TreePath; 13 | 14 | public string Key; 15 | 16 | public Rule() => _Init(); 17 | 18 | public Rule(IEnumerable range) : base(range) => _Init(); 19 | 20 | void _Init() { 21 | TreePath = new TreePath(this,-1); 22 | lock (_counterLock) { 23 | ID = _counter; 24 | _counter ++; 25 | } 26 | } 27 | 28 | public void SetKeyFromTreePath() { 29 | Key = TreePath.Key; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/NonRecursiveFunctionalGrammar/SyntacticBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using OrbitalShell.Component.Console; 4 | 5 | namespace OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar 6 | { 7 | public class SyntacticBlock 8 | { 9 | public string Text; 10 | 11 | public int Index; 12 | 13 | public TreePath SyntacticRule; 14 | 15 | public bool IsSelected; 16 | 17 | public bool IsANSISequence; 18 | 19 | public SyntacticBlock(int index, TreePath syntacticRule, string text, bool isSelected = false, bool isANSISequence = true) 20 | { 21 | Index = index; 22 | SyntacticRule = syntacticRule; 23 | Text = text; 24 | IsSelected = isSelected; 25 | IsANSISequence = isANSISequence; 26 | } 27 | 28 | public override string ToString() 29 | { 30 | return $"{Index}->{Index + Text.Length - 1} : \"{ASCII.GetNonPrintablesCodesAsLabel(Text, false)}\" == {SyntacticRule}"; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/NonRecursiveFunctionalGrammar/SyntacticBlockList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | namespace OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar 6 | { 7 | public class SyntacticBlockList : List 8 | { 9 | public bool IsSelected; 10 | 11 | public SyntacticBlockList Clone( ) { 12 | var r = new SyntacticBlockList(); 13 | r.AddRange(this); 14 | r.IsSelected = IsSelected; 15 | return r; 16 | } 17 | 18 | /// 19 | /// get the real length of the text without ansi sequences non printed characters 20 | /// 21 | /// length of visible part of the text 22 | public int GetTextLength() => GetText().Length; 23 | 24 | /// 25 | /// gets the text part of the syntactic elements 26 | /// 27 | /// string without ansi sequences 28 | public string GetText() => string.Join("",this.Where(x => !x.IsANSISequence).Select(x => x.Text)); 29 | } 30 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/NonRecursiveFunctionalGrammar/TreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | namespace OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar 6 | { 7 | public class TreeNode { 8 | static int _counter = 0; 9 | static object _counterLock = new object(); 10 | public int ID; 11 | public string Label; 12 | public readonly Dictionary SubNodes = new Dictionary(); 13 | 14 | public bool IsRoot => Label == null; 15 | 16 | public TreeNode() { 17 | _Init(); 18 | } 19 | 20 | public TreeNode(string label) { 21 | if (label==null) throw new Exception("label can't be null"); 22 | _Init(); 23 | Label = label; 24 | } 25 | 26 | void _Init() { 27 | lock (_counterLock) { 28 | ID = _counter; 29 | _counter++; 30 | } 31 | } 32 | 33 | public override string ToString() => $" {ID}: {Label} -> {string.Join(" ",SubNodes.Values.Select(x => x.Label))}"; 34 | } 35 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Parser/NonRecursiveFunctionalGrammar/TreePath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | namespace OrbitalShell.Component.Parser.NonRecursiveFunctionalGrammar 6 | { 7 | public class TreePath : List 8 | { 9 | public Rule Rule; 10 | 11 | public int Index; 12 | 13 | public TreePath(Rule rule,int index) { 14 | Rule = rule; 15 | Index = index; 16 | } 17 | 18 | public TreePath(Rule rule,int index,IEnumerable o) : base(o) { 19 | Rule = rule; 20 | Index = index; 21 | } 22 | 23 | public override string ToString() => $"<#{Rule?.ID}> " + string.Join(' ',this.Select(x => x.Label)); 24 | 25 | public string Key => string.Join( '-', this.Select(x => x.ID) ); 26 | } 27 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Script/CSharpScriptEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.CodeAnalysis.CSharp.Scripting; 4 | using Microsoft.CodeAnalysis.Scripting; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | using OrbitalShell.Component.Console; 8 | 9 | namespace OrbitalShell.Component.Script 10 | { 11 | /// 12 | /// c# script engine 13 | /// 14 | public class CSharpScriptEngine 15 | { 16 | readonly Dictionary> _csscripts = new Dictionary>(); 17 | 18 | public ScriptOptions DefaultScriptOptions; 19 | 20 | public CSharpScriptEngine(IConsole console) { _Init(console); } 21 | 22 | public CSharpScriptEngine(IConsole console,ScriptOptions defaultScriptOptions) 23 | { 24 | DefaultScriptOptions = defaultScriptOptions; 25 | _Init(console); 26 | } 27 | 28 | private void _Init(IConsole console) { 29 | 30 | DefaultScriptOptions ??= ScriptOptions.Default; 31 | DefaultScriptOptions = DefaultScriptOptions 32 | .AddImports("System") 33 | .AddReferences(console.GetType().Assembly); 34 | } 35 | 36 | public object ExecCSharp( 37 | string csharpText, 38 | ConsoleTextWriterWrapper @out, 39 | ScriptOptions scriptOptions = null 40 | ) 41 | { 42 | try 43 | { 44 | scriptOptions ??= DefaultScriptOptions; 45 | var scriptKey = csharpText; 46 | if (!_csscripts.TryGetValue(scriptKey, out var script)) 47 | { 48 | script = CSharpScript.Create( 49 | csharpText, 50 | scriptOptions 51 | ); 52 | var cpl = script.Compile(); 53 | _csscripts[scriptKey] = script; 54 | } 55 | var res = script.RunAsync(); 56 | return res.Result.ReturnValue; 57 | } 58 | catch (CompilationErrorException ex) 59 | { 60 | @out?.Errorln($"{csharpText}"); 61 | @out?.Errorln(string.Join(Environment.NewLine, ex.Diagnostics)); 62 | return null; 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/Settings/SettingsBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell_ConsoleApp.Component.Settings 2 | { 3 | /// 4 | /// TODO : settings builder pattern (fluent design) 5 | /// 6 | public class SettingsBuilder 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Component/UI/WorkAreaScrollEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.UI 4 | { 5 | public class WorkAreaScrollEventArgs 6 | : EventArgs 7 | { 8 | public readonly int DeltaX; 9 | public readonly int DeltaY; 10 | 11 | public WorkAreaScrollEventArgs(int deltaX,int deltaY) 12 | { 13 | DeltaX = deltaX; 14 | DeltaY = deltaY; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 02_34_57-Window-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 02_34_57-Window-github.png -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 06_18_08-Window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 06_18_08-Window.png -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 06_36_43-Window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-ConsoleApp/Doc/Images/2020-06-13 06_36_43-Window.png -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Doc/Images/orbital-shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-ConsoleApp/Doc/Images/orbital-shell.png -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) June 2020 franck gaspoz (franck.gaspoz@gmail.com) 2 | Licence Free MIT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the « Software »), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED « AS IS », WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------------------------------ 23 | 24 | Copyright (c) Juin 2020 franck gaspoz (franck.gaspoz@gmail.com) 25 | Licence Libre MIT 26 | 27 | L’autorisation est accordée, gracieusement, à toute personne acquérant une copie 28 | de ce logiciel et des fichiers de documentation associés (le « logiciel »), de commercialiser 29 | le logiciel sans restriction, notamment les droits d’utiliser, de copier, de modifier, 30 | de fusionner, de publier, de distribuer, de sous-licencier et / ou de vendre des copies du logiciel, 31 | ainsi que d’autoriser les personnes auxquelles la logiciel est fournie à le faire, 32 | sous réserve des conditions suivantes : 33 | 34 | La déclaration de copyright ci-dessus et la présente autorisation doivent être incluses dans 35 | toutes copies ou parties substantielles du logiciel. 36 | 37 | LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D’AUCUNE SORTE, EXPLICITE OU IMPLICITE, 38 | NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D’ADÉQUATION À UN USAGE PARTICULIER ET D’ABSENCE 39 | DE CONTREFAÇON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D’AUTEUR NE SERONT RESPONSABLES 40 | DE TOUT DOMMAGE, RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D’UN CONTRAT, 41 | D’UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE LOGICIEL OU SON UTILISATION, 42 | OU AVEC D’AUTRES ÉLÉMENTS DU LOGICIEL. -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Lib/EventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OrbitalShell.Lib 8 | { 9 | /// 10 | /// generic event args + IsCanceled information 11 | /// 12 | /// 13 | public class EventArgs : EventArgs 14 | { 15 | public T Value { get; set; } 16 | 17 | public bool IsCanceled { get; set; } 18 | 19 | public EventArgs(T val) 20 | { 21 | Value = val; 22 | } 23 | 24 | public EventArgs() { } 25 | 26 | public void Recycle() 27 | { 28 | Value = default; 29 | IsCanceled = false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Lib/Process/ProcessCounter.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace OrbitalShell.Lib.Process 4 | { 5 | /// 6 | /// process counter usable with ProcessWrapper 7 | /// 8 | public class ProcessCounter 9 | { 10 | protected int _counter; 11 | protected object _counterLock = new object(); 12 | protected bool _log = true; 13 | 14 | public int Counter { 15 | get 16 | { 17 | lock (_counterLock) 18 | { 19 | return _counter; 20 | } 21 | } 22 | } 23 | 24 | public int GetCounter() 25 | { 26 | return _counter; 27 | } 28 | 29 | public ProcessCounter() 30 | { 31 | this._counter = 0; 32 | } 33 | 34 | public void Increase() { 35 | lock (_counterLock) 36 | { 37 | _counter++; 38 | if (_log) System.Diagnostics.Debug.WriteLine("ProcessCounter:Increased = " + _counter); 39 | } 40 | } 41 | 42 | public void Decrease() { 43 | lock (_counterLock) 44 | { 45 | _counter--; 46 | if (_log) System.Diagnostics.Debug.WriteLine("ProcessCounter:Decreased = " + _counter); 47 | } 48 | } 49 | 50 | public void WaitForLessThan(int N) 51 | { 52 | if (_log) System.Diagnostics.Debug.WriteLine("ProcessCounter:WaitForLessThan " + N); 53 | Thread t = new Thread(() => { WaitForLessThanNInternal(N); }); 54 | t.Start(); 55 | t.Join(); 56 | } 57 | 58 | protected void WaitForLessThanNInternal(int n) 59 | { 60 | bool end = false; 61 | while (!end) 62 | { 63 | int v; 64 | lock (_counterLock) 65 | { 66 | v = GetCounter(); 67 | if (v < n) 68 | end = true; 69 | if (!end) 70 | { 71 | Thread.Yield(); 72 | Thread.Sleep(50); 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Lib/RuntimeEnvironment.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace OrbitalShell.Lib 4 | { 5 | public static class RuntimeEnvironment 6 | { 7 | public static OSPlatform? OSType 8 | { 9 | get 10 | { 11 | OSPlatform? oSPlatform = null; 12 | if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD)) oSPlatform = OSPlatform.FreeBSD; 13 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) oSPlatform = OSPlatform.Windows; 14 | if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) oSPlatform = OSPlatform.OSX; 15 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) oSPlatform = OSPlatform.Linux; 16 | return oSPlatform; 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Lib/TargetPlatform.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Lib 2 | { 3 | /// 4 | /// based on System.Runtime.RuntimeEnvironment 5 | /// 6 | public enum TargetPlatform 7 | { 8 | FreeBSD, 9 | Linux, 10 | OSX, 11 | Windows, 12 | Any, 13 | Unspecified 14 | } 15 | } -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/README.md: -------------------------------------------------------------------------------- 1 | # Orbital Shell - ConsoleApp 2 | Orbital Shell ConsoleApp library (previously "Dot Net Console App Toolkit") helps build fastly nice multi-plateform (windows, osx, arm) console applications using C# and .NET Core 3.1 and .NET Standard 2.1 3 | 4 | [![licence mit](https://img.shields.io/badge/licence-MIT-blue.svg)](license.md) This project is licensed under the terms of the MIT license: [LICENSE.md](LICENSE.md) 5 | 6 | ![last commit](https://img.shields.io/github/last-commit/franck-gaspoz/dotnet-console-app-toolkit?style=plastic) 7 | ![version](https://img.shields.io/github/v/tag/franck-gaspoz/dotnet-console-app-toolkit?style=plastic) 8 | 9 | # Features 10 | 11 | The toolkit provides functionalities needed to build console applications running in a terminal (WSL/WSL2, cmd.exe, ConEmu, bash, ...) with text interface. That includes: 12 | - a text printer engine that supports print directives allowing to manage console functionalities from text itself, as html would do but with a simplest grammar (that can be configured). That makes possible colored outputs, cursor control, text scrolling and also dynamic C# execution (scripting), based on several APIs like System.Console and ANSI VT100 / VT52. The print directives are available as commands strings, as a command from the integrated shell or from an underlying shell 13 | 14 | ``` csharp 15 | // -- example of a string containing print directives -- 16 | 17 | // 1) from the toolkit shell command line: 18 | echo "(br,f=yellow,b=red)yellow text on red background(br)(f=cyan)current time is: (exec=System.DateTime.Now,br)" 19 | 20 | // 2) invoking the toolkit: 21 | orbsh.exe "(br,f=yellow,b=red)yellow text on red background(br)(f=cyan)current time is: (exec=System.DateTime.Now,br)" 22 | 23 | // 3) from C# using DotNetConsole.cs 24 | Echo($"{Br}{Yellow}{BRed}yellow text on red background{Br}{Cyan}current time is: {System.DateTime.Now}{Br}"); 25 | ``` 26 | 27 | 28 | - UI controls for displaying texts and graphical characters in a various way and handling user inputs 29 | 30 | - libraries of methods for performing various print operations, data conversions, process management, .. 31 | 32 | - data types related to the system and the environment that provides usefull methods 33 | -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/Temp/this is an embeded temp folder.txt: -------------------------------------------------------------------------------- 1 | this is an embeded temp folder -------------------------------------------------------------------------------- /OrbitalShell-ConsoleApp/assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-ConsoleApp/assets/robotazteque.png -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/CommandLineProcessor/banner-2.txt: -------------------------------------------------------------------------------- 1 |  2 | ▒█████ ██▀███ ▄▄▄▄ ██▓▄▄▄█████▓ ▄▄▄ ██▓ 3 | ▒██▒ ██▒▓██ ▒ ██▒▓█████▄ ▓██▒▓ ██▒ ▓▒▒████▄ ▓██▒ 4 | ▒██░ ██▒▓██ ░▄█ ▒▒██▒ ▄██▒██▒▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ 5 | ▒██ ██░▒██▀▀█▄ ▒██░█▀ ░██░░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ 6 | ░ ████▓▒░░██▓ ▒██▒░▓█ ▀█▓░██░ ▒██▒ ░ ▓█ ▓██▒░██████▒ (SGR_SlowBlink)Shell 7 | ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░▒▓███▀▒░▓ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░ 8 | ░ ▒ ▒░ ░▒ ░ ▒░▒░▒ ░ ▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░ 9 | ░ ░ ░ ▒ ░░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ 11 | ░ -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/CommandLineProcessor/banner-3.txt: -------------------------------------------------------------------------------- 1 |  2 | ██████╗ ██████╗ ██████╗ ██╗████████╗ █████╗ ██╗ 3 | ██╔═══██╗██╔══██╗██╔══██╗██║╚══██╔══╝██╔══██╗██║ 4 | ██║ ██║██████╔╝██████╔╝██║ ██║ ███████║██║ 5 | ██║ ██║██╔══██╗██╔══██╗██║ ██║ ██╔══██║██║ 6 | ╚██████╔╝██║ ██║██████╔╝██║ ██║ ██║ ██║███████╗ Shell 7 | ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/CommandLineProcessor/banner-4.txt: -------------------------------------------------------------------------------- 1 |  2 | ▒█████ ██▀███ ▄▄▄▄ ██▓▄▄▄█████▓ ▄▄▄ ██▓ 3 | ▒██▒ ██▒▓██ ▒ ██▒▓█████▄ ▓██▒▓ ██▒ ▓▒▒████▄ ▓██▒ 4 | ▒██░ ██▒▓██ ░▄█ ▒▒██▒ ▄██▒██▒▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ 5 | ▒██ ██░▒██▀▀█▄ ▒██░█▀ ░██░░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ 6 | ░ ████▓▒░░██▓ ▒██▒░▓█ ▀█▓░██░ ▒██▒ ░ ▓█ ▓██▒░██████▒ Shell 7 | ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░▒▓███▀▒░▓ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░ 8 | ░ ▒ ▒░ ░▒ ░ ▒░▒░▒ ░ ▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░ 9 | ░ ░ ░ ▒ ░░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ 10 | ░ ░ ░ ░ ░ ░ ░ ░ ░ 11 | ░ -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/CommandLineProcessor/banner.txt: -------------------------------------------------------------------------------- 1 |  ___ ___ ___ ___ ___ ___ 2 | /\ \ /\ \ /\ \ ___ /\ \ /\ \ /\__\ 3 | /::\ \ /::\ \ /::\ \ /\ \ \:\ \ /::\ \ /:/ / 4 | /:/\:\ \ /:/\:\ \ /:/\:\ \ \:\ \ \:\ \ /:/\:\ \ /:/ / 5 | /:/ \:\ \ /::\~\:\ \ /::\~\:\__\ /::\__\ /::\ \ /::\~\:\ \ /:/ / 6 | /:/__/ \:\__\ /:/\:\ \:\__\ /:/\:\ \:|__| __/:/\/__/ /:/\:\__\ /:/\:\ \:\__\ /:/__/ 7 | \:\ \ /:/ / \/_|::\/:/ / \:\~\:\/:/ / /\/:/ / /:/ \/__/ \/__\:\/:/ / \:\ \ 8 | \:\ /:/ / |:|::/ / \:\ \::/ / \::/__/ /:/ / \::/ / \:\ \ 9 | \:\/:/ / |:|\/__/ \:\/:/ / \:\__\ \/__/ /:/ / \:\ \ 10 | \::/ / |:| | \::/__/ \/__/ /:/ / \:\__\ 11 | \/__/ \|__| ~~ \/__/ \/__/ Shell -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/FileSystem/DirSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Commands.FileSystem 4 | { 5 | [Flags] 6 | public enum DirSort 7 | { 8 | /// 9 | /// sort not specified 10 | /// 11 | not_specified = 0, 12 | 13 | /// 14 | /// sort by name or fullname 15 | /// 16 | name = 1, 17 | 18 | /// 19 | /// sort by size 20 | /// 21 | size = 2, 22 | 23 | /// 24 | /// sort by extension 25 | /// 26 | ext = 4, 27 | 28 | /// 29 | /// files on top 30 | /// 31 | file = 8, 32 | 33 | /// 34 | /// dirs on top 35 | /// 36 | dir = 16, 37 | 38 | /// 39 | /// reverse sort 40 | /// 41 | rev = 32 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/Http/HttpCommands.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OrbitalShell.Component.CommandLine.CommandModel; 3 | using OrbitalShell.Component.CommandLine.Processor; 4 | using OrbitalShell.Component.Shell; 5 | using System.Net.Http; 6 | 7 | namespace OrbitalShell.Commands.Http 8 | { 9 | [Commands("http commands")] 10 | [CommandsNamespace(CommandNamespace.net,CommandNamespace.http)] 11 | public class HttpCommands : ICommandsDeclaringType 12 | { 13 | [Command("get")] 14 | public CommandResult Get( 15 | CommandEvaluationContext context, 16 | [Parameter("query string")] string queryString, 17 | [Option("q","quiet","if not set (default), output get result on stdout",false,true)] bool quiet = false, 18 | [Option("b","bin","get as a binary stream",false,true)] bool binary = false 19 | ) 20 | { 21 | object @return = null; 22 | if (string.IsNullOrWhiteSpace(queryString)) 23 | { 24 | context.Errorln("uri must not be empty"); 25 | return new CommandResult(HttpContentBody.EmptyHttpContentBody); 26 | } 27 | if (!queryString.ToLower().StartsWith("http://") && !queryString.ToLower().StartsWith("https://")) 28 | queryString = "http://" + queryString; 29 | 30 | using (var httpClient = new HttpClient()) 31 | { 32 | using var request = new HttpRequestMessage(new HttpMethod("GET"), queryString); 33 | var tsk = httpClient.SendAsync(request); 34 | var result = tsk.Result; 35 | if (result.IsSuccessStatusCode) 36 | { 37 | //@return = result.Content.ReadAsStringAsync().Result; 38 | @return = 39 | !binary ? 40 | result.Content.ReadAsStringAsync().Result : 41 | result.Content.ReadAsByteArrayAsync().Result; 42 | 43 | if (!quiet) context.Out.Echo(@return, true, true); 44 | } 45 | else 46 | context.Errorln($"can't get response content: {result.ReasonPhrase}"); 47 | } 48 | 49 | return new CommandResult(new HttpContentBody(@return)); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/Http/HttpContentBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace OrbitalShell.Commands.Http 6 | { 7 | /// 8 | /// http get result content 9 | /// 10 | public class HttpContentBody 11 | { 12 | public static readonly HttpContentBody EmptyHttpContentBody = new HttpContentBody(); 13 | 14 | public object Content; 15 | 16 | public HttpContentBody() { } 17 | 18 | public HttpContentBody(object content) 19 | { 20 | Content = content; 21 | } 22 | 23 | public HttpContentBody(byte[] data) 24 | { 25 | Content = data; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/NuGetServerApi/PackageType.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Console; 2 | 3 | namespace OrbitalShell.Commands.NuGetServerApi 4 | { 5 | public class PackageType 6 | { 7 | public string Name; 8 | 9 | public override string ToString() => Name; 10 | 11 | /// 12 | /// Echo method 13 | /// 14 | /// echo context 15 | public void Echo(EchoEvaluationContext context) 16 | { 17 | context.Out.Echo(Name,context.Options.LineBreak,context.Options.IsRawModeEnabled); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/NuGetServerApi/PackageVersionInfos.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Console; 2 | 3 | namespace OrbitalShell.Commands.NuGetServerApi 4 | { 5 | public class PackageVersionInfos 6 | { 7 | public string Version; 8 | public int Downloads; 9 | 10 | public override string ToString() => $"Version={Version} Downloads={Downloads}"; 11 | 12 | /// 13 | /// Echo method 14 | /// 15 | /// echo context 16 | public void Echo(EchoEvaluationContext context) 17 | { 18 | context.Out.Echo($"Version={Version} Downloads={Downloads}", context.Options.LineBreak, context.Options.IsRawModeEnabled); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/NuGetServerApi/PackageVersions.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Commands.NuGetServerApi 2 | { 3 | public class PackageVersions 4 | { 5 | public string[] Versions; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/NuGetServerApi/QueryResultRoot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | using OrbitalShell.Component.Console; 5 | 6 | namespace OrbitalShell.Commands.NuGetServerApi 7 | { 8 | public class QueryResultRoot 9 | { 10 | public int TotalHits; 11 | 12 | public Package[] Data; 13 | 14 | public override string ToString() 15 | { 16 | var r = Environment.NewLine; 17 | string sep = "".PadLeft(30, '-') + r; 18 | return ($"TotalHits={TotalHits}{r}" + 19 | ((Data != null && Data.Length > 0) ? 20 | $"Packages list:{r}" + $"{string.Join("", Data.Select(x => sep + x.ToString()))}" 21 | : "")).Trim(); 22 | } 23 | 24 | /// 25 | /// Echo method 26 | /// 27 | /// echo context 28 | public void Echo(EchoEvaluationContext context) 29 | { 30 | var cols = context.CommandEvaluationContext.ShellEnv.Colors; 31 | var r = cols.Default + Environment.NewLine; 32 | var s = $"{cols.HighlightSymbol}TotalHits"; 33 | s += $"{cols.Default}="; 34 | s += $"{cols.Numeric}{TotalHits}{cols.Default}"; 35 | context.Out.Echoln(s); 36 | if (Data != null && Data.Length > 0) 37 | { 38 | context.Out.Echoln( $"{r}Packages list:{r}" ); 39 | int i = 1; 40 | foreach (var item in Data) 41 | { 42 | item.Echo(context); 43 | if (i < Data.Length) 44 | context.Out.Echoln(); 45 | i++; 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/Shell/ShellCommands.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine; 2 | using OrbitalShell.Component.Shell; 3 | using OrbitalShell.Component.CommandLine.CommandModel; 4 | using OrbitalShell.Component.CommandLine.Processor; 5 | 6 | namespace OrbitalShell.Commands.Shell 7 | { 8 | [Commands("commands of the command line processor")] 9 | [CommandsNamespace(CommandNamespace.shell)] 10 | public partial class ShellCommands : ICommandsDeclaringType 11 | { 12 | #region app 13 | 14 | [Command("exit the shell")] 15 | [CommandNamespace(CommandNamespace.shell, CommandNamespace.app)] 16 | public CommandResult Exit( 17 | CommandEvaluationContext context 18 | ) 19 | { 20 | context.CommandLineProcessor.Console.Exit(); 21 | return new CommandResult(0); 22 | } 23 | 24 | [Command("print command processor infos")] 25 | public CommandVoidResult Cpinfo( 26 | CommandEvaluationContext context 27 | ) 28 | { 29 | context.CommandLineProcessor.PrintInfo(context); 30 | return new CommandVoidResult(); 31 | } 32 | 33 | #endregion 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/TextEditor/EditorBackup.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Console; 2 | using OrbitalShell.Lib.FileSystem; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace OrbitalShell.Commands.TextEditor 9 | { 10 | public class EditorBackup 11 | { 12 | public readonly bool RawMode; 13 | public readonly FilePath FilePath; 14 | public readonly string EOLSeparator; 15 | public readonly bool ReadOnly; 16 | public readonly bool FileModified; 17 | public readonly long FileSize = 0; 18 | public readonly int FirstLine = 0; 19 | public readonly int CurrentLine = 0; 20 | public readonly int X = 0; 21 | public readonly int Y = 0; 22 | public readonly List Text; 23 | public readonly List> LinesSplits; 24 | public readonly Encoding FileEncoding; 25 | public readonly OSPlatform? FileEOL; 26 | public readonly Point BeginOfLineCurPos; 27 | public readonly int LastVisibleLineIndex; 28 | public readonly int SplitedLastVisibleLineIndex; 29 | 30 | public EditorBackup( 31 | bool rawMode, 32 | FilePath filePath, 33 | string eolSeparator, 34 | bool readOnly, 35 | bool fileModified, 36 | long fileSize, 37 | int firstLine, 38 | int currentLine, 39 | int x, 40 | int y, 41 | List text, 42 | List> linesSplits, 43 | Encoding fileEncoding, 44 | OSPlatform? fileEOL, 45 | Point beginOfLineCurPos, 46 | int lastVisibleLineIndex, 47 | int splitedLastVisibleLineIndex) 48 | { 49 | RawMode = false; 50 | FilePath = filePath; 51 | EOLSeparator = eolSeparator; 52 | ReadOnly = readOnly; 53 | FileModified = fileModified; 54 | FileSize = fileSize; 55 | FirstLine = firstLine; 56 | CurrentLine = currentLine; 57 | X = x; 58 | Y = y; 59 | Text = new List(); 60 | Text.AddRange(text); 61 | LinesSplits = new List>(); 62 | LinesSplits.AddRange(linesSplits); 63 | FileEncoding = fileEncoding; 64 | FileEOL = fileEOL; 65 | BeginOfLineCurPos = beginOfLineCurPos; 66 | LastVisibleLineIndex = lastVisibleLineIndex; 67 | SplitedLastVisibleLineIndex = splitedLastVisibleLineIndex; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/TextEditor/edit-help.txt: -------------------------------------------------------------------------------- 1 | (f=cyan)(uon) Dot Net Shell Edit - version 1.0.0.0 (uoff) 2 | 3 | The command (f=yellow)edit(f=white) runs a text file editor in any VT100/VT52 console on OS Windows,Linux,OSX. 4 | This text editor supports the (uon)Dot Net Console Toolkit(uoff) print directives syntax. 5 | Press the key (f=darkyellow)Esc(f=white) to display/toggle an information bar that displays available commands. 6 | 7 | The list of available commands is: 8 | 9 | (uon)application commands:(uoff) 10 | 11 | (f=cyan)[Esc](f=white) : displays the command bar, toggle to next command bar, hide the command bar 12 | (f=cyan)[Esc]V|v(f=white) : toggle the bar visibility 13 | (f=cyan)[Esc]I|i(f=white) : displays the file information bar 14 | (f=cyan)[F1](f=white) : displays the help file (this file) 15 | (f=cyan)[Esc]S|s(f=white) : Save the current file 16 | (f=cyan)[Esc]L|l(f=white) : Load a file 17 | (f=cyan)[Esc]Q|q(f=white) : Quit the current editor and restore the previous file if any, or else returns to underlying shell 18 | (f=cyan)[Esc]X|x(f=white) : Exit from all editor and returns to underlying shell. Discard all changes 19 | 20 | (uon)edit commands:(uoff) 21 | 22 | (f=cyan)[Esc]T|t (f=white) : go to top of the file 23 | (f=cyan)[Esc]B|b (f=white) : go to bottom of the file 24 | (f=cyan)[Esc]A|a (f=white) : go to previous page if any 25 | (f=cyan)[Esc]Z|z (f=white) : go to next page if any 26 | (f=cyan)[Esc]B|c (f=white) : clear the file 27 | (f=cyan)[Esc]N|n (f=white) : leave current file and begin the edition of a new file 28 | 29 | (uon)settings:(uoff) 30 | 31 | (f=cyan)[Esc]R|r (f=white) : toggle raw mode: enable/disable evaluation of print directives 32 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/Commands/TextFile/TextFileInfo.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Lib.FileSystem; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace OrbitalShell.Commands.TextFile 5 | { 6 | public class TextFileInfo 7 | { 8 | public readonly FilePath File; 9 | public readonly string[] TextLines; 10 | public readonly OSPlatform OSPlatform; 11 | public readonly string Eol; 12 | 13 | public TextFileInfo(FilePath file, string[] textLines, OSPlatform oSPlatform, string eol) 14 | { 15 | File = file; 16 | TextLines = textLines; 17 | OSPlatform = oSPlatform; 18 | Eol = eol; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) June 2020 franck gaspoz (franck.gaspoz@gmail.com) 2 | Licence Free MIT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the « Software »), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED « AS IS », WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------------------------------ 23 | 24 | Copyright (c) Juin 2020 franck gaspoz (franck.gaspoz@gmail.com) 25 | Licence Libre MIT 26 | 27 | L’autorisation est accordée, gracieusement, à toute personne acquérant une copie 28 | de ce logiciel et des fichiers de documentation associés (le « logiciel »), de commercialiser 29 | le logiciel sans restriction, notamment les droits d’utiliser, de copier, de modifier, 30 | de fusionner, de publier, de distribuer, de sous-licencier et / ou de vendre des copies du logiciel, 31 | ainsi que d’autoriser les personnes auxquelles la logiciel est fournie à le faire, 32 | sous réserve des conditions suivantes : 33 | 34 | La déclaration de copyright ci-dessus et la présente autorisation doivent être incluses dans 35 | toutes copies ou parties substantielles du logiciel. 36 | 37 | LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D’AUCUNE SORTE, EXPLICITE OU IMPLICITE, 38 | NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D’ADÉQUATION À UN USAGE PARTICULIER ET D’ABSENCE 39 | DE CONTREFAÇON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D’AUTEUR NE SERONT RESPONSABLES 40 | DE TOUT DOMMAGE, RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D’UN CONTRAT, 41 | D’UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE LOGICIEL OU SON UTILISATION, 42 | OU AVEC D’AUTRES ÉLÉMENTS DU LOGICIEL. -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/ModuleInfo.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Shell.Module; 2 | using OrbitalShell.Lib; 3 | 4 | // declare a shell module 5 | 6 | [assembly: ShellModule("OrbitalShell-Kernel-Commands")] 7 | [assembly: ModuleTargetPlateform(TargetPlatform.Any)] 8 | [assembly: ModuleShellMinVersion("1.0.9")] 9 | [assembly: ModuleAuthors("Orbital Shell team")] 10 | namespace OrbitalShell.Kernel.Commands 11 | { 12 | public class ModuleInfo { } 13 | } 14 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel-Commands/assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-Kernel-Commands/assets/robotazteque.png -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Batch/CommandBatchProcessor.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | using OrbitalShell.Lib; 3 | using static OrbitalShell.Component.CommandLine.Parsing.CommandLineSyntax; 4 | using System; 5 | 6 | namespace OrbitalShell.Component.CommandLine.Batch 7 | { 8 | public class CommandBatchProcessor : ICommandBatchProcessor 9 | { 10 | public int RunBatch(CommandEvaluationContext context, string path) 11 | { 12 | var (lines, _, _) = TextFileReader.ReadAllLines(path); 13 | return RunBatch(context, lines); 14 | } 15 | 16 | public int RunBatchText(CommandEvaluationContext context, string batch) 17 | { 18 | if (string.IsNullOrWhiteSpace(batch)) return (int)ReturnCode.OK; 19 | var lines = batch.Split(Environment.NewLine); 20 | return RunBatch(context, lines); 21 | } 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Marquer les membres comme étant static", Justification = "")] 24 | int RunBatch(CommandEvaluationContext context, string[] batchLines) 25 | { 26 | var ret = (int)ReturnCode.OK; 27 | foreach (var line in batchLines) 28 | { 29 | var s = line.Trim(); 30 | if (!s.StartsWith(BatchCommentBegin) && !string.IsNullOrEmpty(s)) 31 | { 32 | var r = context.CommandLineProcessor.Eval(context, s, 0); 33 | if (r.EvalResultCode != (int)ReturnCode.OK) ret = (int)ReturnCode.Error; 34 | } 35 | } 36 | return ret; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Batch/ICommandBatchProcessor.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Batch 4 | { 5 | public interface ICommandBatchProcessor 6 | { 7 | int RunBatch(CommandEvaluationContext context, string path); 8 | int RunBatchText(CommandEvaluationContext context, string batch); 9 | } 10 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandAliasAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)] 6 | public class CommandAliasAttribute : Attribute 7 | { 8 | public string AliasName; 9 | public string AliasText; 10 | 11 | public CommandAliasAttribute(string aliasName, string aliasText) 12 | { 13 | AliasName = aliasName; 14 | AliasText = aliasText; 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Method,AllowMultiple =false,Inherited =false)] 6 | public class CommandAttribute : Attribute 7 | { 8 | public readonly string Description; 9 | public readonly string LongDescription; 10 | public readonly string Name; 11 | public readonly string Documentation; 12 | 13 | public CommandAttribute(string description,string longDescription=null,string documentation=null,string name=null) 14 | { 15 | Description = description; 16 | Documentation = documentation; 17 | LongDescription = longDescription; 18 | Name = name; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Method,AllowMultiple =false,Inherited =false)] 6 | public class CommandNameAttribute : Attribute 7 | { 8 | public readonly string Name; 9 | 10 | public CommandNameAttribute(string name=null) 11 | { 12 | Name = name; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandNamespaceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using OrbitalShell.Component.Shell; 5 | 6 | namespace OrbitalShell.Component.CommandLine.CommandModel 7 | { 8 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] 9 | public class CommandNamespaceAttribute : Attribute 10 | { 11 | public readonly string[] Segments; 12 | 13 | public CommandNamespaceAttribute(params string[] segments) 14 | { 15 | Segments = segments; 16 | } 17 | 18 | public CommandNamespaceAttribute(CommandNamespace rootNamespace, params string[] segments) 19 | { 20 | var s = new List { rootNamespace + "" }; 21 | s.AddRange(segments); 22 | Segments = s.ToArray(); 23 | } 24 | 25 | public CommandNamespaceAttribute(params CommandNamespace[] segments) 26 | { 27 | Segments = segments.Select(x => x + "").ToArray(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Class,AllowMultiple =false,Inherited =true)] 6 | public class CommandsAttribute : Attribute 7 | { 8 | public readonly string Description; 9 | 10 | public CommandsAttribute(string description) 11 | { 12 | Description = description; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CommandsNamespaceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using OrbitalShell.Component.Shell; 5 | 6 | namespace OrbitalShell.Component.CommandLine.CommandModel 7 | { 8 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] 9 | public class CommandsNamespaceAttribute : Attribute 10 | { 11 | public readonly string[] Segments; 12 | 13 | public CommandsNamespaceAttribute(params string[] segments) 14 | { 15 | Segments = segments; 16 | } 17 | 18 | public CommandsNamespaceAttribute(CommandNamespace @namespace) 19 | { 20 | Segments = new string[] { "" + @namespace }; 21 | } 22 | 23 | public CommandsNamespaceAttribute(params CommandNamespace[] segments) 24 | { 25 | Segments = segments.Select(x => x + "").ToArray(); 26 | } 27 | 28 | public CommandsNamespaceAttribute(CommandNamespace @namespace, params string[] segments) 29 | { 30 | var s = new List { "" + @namespace }; 31 | s.AddRange(segments); 32 | Segments = s.ToArray(); 33 | } 34 | 35 | public CommandsNamespaceAttribute(CommandNamespace @namespace1, CommandNamespace @namespace2, params string[] segments) 36 | { 37 | var s = new List { "" + @namespace1 , "" + @namespace2 }; 38 | s.AddRange(segments); 39 | Segments = s.ToArray(); 40 | } 41 | 42 | public CommandsNamespaceAttribute(CommandNamespace @namespace1, CommandNamespace @namespace2, CommandNamespace @namespace3, params string[] segments) 43 | { 44 | var s = new List { "" + @namespace1, "" + @namespace2 , "" + namespace3 }; 45 | s.AddRange(segments); 46 | Segments = s.ToArray(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/CustomParameterType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Class,AllowMultiple =false,Inherited =true )] 6 | public class CustomParameterType : Attribute 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/ICommandsDeclaringType.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.CommandLine.CommandModel 2 | { 3 | /// 4 | /// remove - unsefull - [Commands(..)] is enough 5 | /// 6 | public interface ICommandsDeclaringType 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/OptionRequireParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Parameter,AllowMultiple =true,Inherited =false)] 6 | public class OptionRequireParameterAttribute : Attribute 7 | { 8 | public readonly string RequiredParameterName; 9 | 10 | public OptionRequireParameterAttribute(string requiredParameterName) 11 | { 12 | RequiredParameterName = requiredParameterName; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/CommandModel/RequireOSCommandAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.CommandModel 4 | { 5 | [AttributeUsage(AttributeTargets.Method,AllowMultiple = true,Inherited = false)] 6 | public class RequireOSCommandAttribute : Attribute 7 | { 8 | public readonly string CommandName; 9 | 10 | public RequireOSCommandAttribute(string commandName) 11 | { 12 | CommandName = commandName; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/AmbiguousParameterSpecificationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class AmbiguousParameterSpecificationException : Exception 6 | { 7 | public AmbiguousParameterSpecificationException( string message ) : base(message) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/CommandSyntaxParsingResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class CommandSyntaxParsingResult 6 | { 7 | public readonly CommandSyntax CommandSyntax; 8 | public readonly MatchingParameters MatchingParameters; 9 | public readonly List ParseErrors; 10 | 11 | public CommandSyntaxParsingResult( 12 | CommandSyntax commandSyntax, 13 | MatchingParameters matchingParameters, 14 | List parseErrors 15 | ) 16 | { 17 | CommandSyntax = commandSyntax; 18 | MatchingParameters = matchingParameters; 19 | ParseErrors = parseErrors; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/ExternalParserExtensionContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OrbitalShell.Component.CommandLine.Processor; 3 | 4 | namespace OrbitalShell.Component.CommandLine.Parsing 5 | { 6 | public class ExternalParserExtensionContext 7 | { 8 | public readonly CommandEvaluationContext Context; 9 | public readonly string TokenName; 10 | public readonly string[] Args; 11 | public readonly string Expr; 12 | 13 | public ExternalParserExtensionContext( 14 | CommandEvaluationContext context, 15 | string tokenName, 16 | string[] args, 17 | string expr 18 | ) 19 | { 20 | Context = context; 21 | TokenName = tokenName; 22 | Args = args; 23 | Expr = expr; 24 | } 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/IExternalParserExtension.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | using OrbitalShell.Component.CommandLine.Processor; 3 | 4 | namespace OrbitalShell.Component.CommandLine.Parsing 5 | { 6 | /// 7 | /// command line parse extension class interface 8 | /// 9 | public interface IExternalParserExtension 10 | { 11 | ICommandLineProcessor CommandLineProcessor { get; set; } 12 | 13 | bool TryGetCommandSpecificationFromExternalToken( 14 | ExternalParserExtensionContext externalParserExtensionContext, 15 | out CommandSpecification commandSpecification, 16 | out string commandPath 17 | ); 18 | } 19 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/IMatchingParameter.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public interface IMatchingParameter 6 | { 7 | CommandParameterSpecification CommandParameterSpecification { get; } 8 | object GetValue(); 9 | void SetValue(object value); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/ISyntaxAnalyser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using OrbitalShell.Component.CommandLine.CommandModel; 5 | 6 | namespace OrbitalShell.Component.CommandLine.Parsing 7 | { 8 | public interface ISyntaxAnalyser 9 | { 10 | void Add(CommandSpecification comSpec); 11 | List FindSyntaxesFromToken(string token, bool partialTokenMatch = false, StringComparison comparisonType = StringComparison.CurrentCulture); 12 | void Remove(CommandSpecification comSpec); 13 | } 14 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/MatchingParameter.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class MatchingParameter : IMatchingParameter 6 | { 7 | public CommandParameterSpecification CommandParameterSpecification { get; protected set; } 8 | public T Value { get; protected set; } 9 | public bool IsCustom { get; protected set; } 10 | 11 | public object GetValue() => Value; 12 | 13 | public void SetValue(object value) 14 | { 15 | Value = (T)value; 16 | } 17 | 18 | public MatchingParameter(CommandParameterSpecification commandParameterSpecification, T value,bool isCustom = false) 19 | { 20 | Value = value; 21 | CommandParameterSpecification = commandParameterSpecification; 22 | IsCustom = isCustom; 23 | } 24 | 25 | public MatchingParameter(CommandParameterSpecification commandParameterSpecification, bool isCustom = false) 26 | { 27 | CommandParameterSpecification = commandParameterSpecification; 28 | IsCustom = isCustom; 29 | } 30 | 31 | public override string ToString() 32 | { 33 | return $"{CommandParameterSpecification} = {Value}"; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/MatchingParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace OrbitalShell.Component.CommandLine.Parsing 5 | { 6 | public class MatchingParameters 7 | { 8 | readonly Dictionary _parameters 9 | = new Dictionary(); 10 | 11 | public ReadOnlyDictionary Parameters => 12 | new ReadOnlyDictionary(_parameters); 13 | 14 | public bool Contains(string parameterName) => _parameters.ContainsKey(parameterName); 15 | 16 | public bool TryGet(string parameterName,out IMatchingParameter matchingParameter) 17 | { 18 | return _parameters.TryGetValue(parameterName, out matchingParameter); 19 | } 20 | 21 | public void Add(string parameterName, IMatchingParameter matchingParameter) 22 | { 23 | _parameters.Add(parameterName, matchingParameter); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/ParseErrorException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class ParseErrorException : Exception 6 | { 7 | public readonly ParseError ParseError; 8 | 9 | public ParseErrorException(ParseError parseError) : base(parseError.Description) 10 | { 11 | ParseError = parseError; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/ParseResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class ParseResult 6 | { 7 | public readonly ParseResultType ParseResultType; 8 | public readonly List SyntaxParsingResults; 9 | 10 | public ParseResult( 11 | ParseResultType parseResultType, 12 | List syntaxParsingResults 13 | ) 14 | { 15 | ParseResultType = parseResultType; 16 | SyntaxParsingResults = syntaxParsingResults; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/ParseResultType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace OrbitalShell.Component.CommandLine.Parsing 6 | { 7 | public enum ParseResultType 8 | { 9 | Valid, 10 | NotValid, 11 | NotIdentified, 12 | Empty, 13 | Ambiguous, 14 | SyntaxError 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/PipelineParseResult.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Pipeline; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class PipelineParseResult 6 | { 7 | public readonly ParseResult ParseResult; 8 | public readonly PipelineWorkUnit WorkUnit; 9 | public PipelineParseResult Next; 10 | public string Expr; 11 | 12 | public PipelineParseResults PipelineParseResults; 13 | 14 | public PipelineParseResult(string expr, PipelineParseResults pipelineParseResults, PipelineWorkUnit workUnit, ParseResult parseResult) 15 | { 16 | ParseResult = parseResult; 17 | PipelineParseResults = pipelineParseResults; 18 | WorkUnit = workUnit; 19 | Expr = expr; 20 | } 21 | 22 | public PipelineParseResult(string expr, PipelineParseResults pipelineParseResults, ParseResult parseResult) 23 | { 24 | ParseResult = parseResult; 25 | PipelineParseResults = pipelineParseResults; 26 | Expr = expr; 27 | } 28 | 29 | public PipelineParseResult(string expr, PipelineParseResults pipelineParseResults, PipelineWorkUnit workUnit) 30 | { 31 | ParseResult = new ParseResult(ParseResultType.Empty, null); 32 | PipelineParseResults = pipelineParseResults; 33 | WorkUnit = workUnit; 34 | Expr = expr; 35 | } 36 | 37 | public PipelineParseResult(PipelineParseResults pipelineParseResults) 38 | { 39 | PipelineParseResults = pipelineParseResults; 40 | ParseResult = new ParseResult(ParseResultType.Empty, null); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/PipelineParseResults.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.CommandLine.Parsing 4 | { 5 | public class PipelineParseResults : List 6 | { 7 | public PipelineParseResults() { } 8 | 9 | public PipelineParseResults(PipelineParseResult pipelineParseResult) 10 | { 11 | Add(pipelineParseResult); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Parsing/SyntaxAnalyser.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | using System; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using OrbitalShell.Component.CommandLine.Processor; 6 | 7 | namespace OrbitalShell.Component.CommandLine.Parsing 8 | { 9 | public class SyntaxAnalyser : ISyntaxAnalyser 10 | { 11 | readonly Dictionary> _syntaxes 12 | = new Dictionary>(); 13 | 14 | public void Add(CommandSpecification comSpec) 15 | { 16 | if (_syntaxes.TryGetValue(comSpec.Name, out var lst)) 17 | lst.Add(new CommandSyntax(comSpec)); 18 | else 19 | _syntaxes.Add(comSpec.Name, new List { new CommandSyntax(comSpec) }); 20 | } 21 | 22 | public void Remove(CommandSpecification comSpec) 23 | { 24 | if (_syntaxes.TryGetValue(comSpec.Name, out var lst)) 25 | { 26 | var sytx = lst.Where(x => x.CommandSpecification == comSpec).FirstOrDefault(); 27 | if (sytx != null) 28 | { 29 | lst.Remove(sytx); 30 | if (lst.Count == 0) 31 | _syntaxes.Remove(comSpec.Name); 32 | } 33 | } 34 | } 35 | 36 | public List FindSyntaxesFromToken( 37 | string token, 38 | bool partialTokenMatch = false, 39 | StringComparison comparisonType = StringComparison.CurrentCulture 40 | ) 41 | { 42 | var r = new List(); 43 | foreach (var ctokenkv in _syntaxes) 44 | { 45 | var ctoken = ctokenkv.Key; 46 | 47 | if ((partialTokenMatch && ctoken.StartsWith(token, comparisonType)) 48 | || ctoken.Equals(token, comparisonType)) 49 | r.AddRange(_syntaxes[ctoken]); 50 | 51 | foreach (var sn in ctokenkv.Value) 52 | { 53 | var fullname = sn.CommandSpecification.FullName; 54 | if ((partialTokenMatch && fullname.StartsWith(token, comparisonType)) 55 | || fullname.Equals(token, comparisonType)) 56 | r.AddRange(_syntaxes[ctoken]); 57 | } 58 | } 59 | return r; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Pipeline/PipelineCondition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace OrbitalShell.Component.CommandLine.Pipeline 6 | { 7 | public enum PipelineCondition 8 | { 9 | NotAppliable, 10 | Always, 11 | Success, 12 | Error 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Pipeline/PipelineWorkUnit.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Parsing; 2 | using OrbitalShell.Component.Console; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using static OrbitalShell.Component.EchoDirective.Shortcuts; 6 | 7 | namespace OrbitalShell.Component.CommandLine.Pipeline 8 | { 9 | public class PipelineWorkUnit 10 | { 11 | public List Segments = new List(); 12 | 13 | public int StartIndex; 14 | public int EndIndex; 15 | 16 | public string Command; 17 | 18 | public PipelineWorkUnit NextUnit; 19 | 20 | public PipelineCondition PipelineCondition = PipelineCondition.NotAppliable; 21 | public StringSegment HereScript = null; 22 | public StringSegment InputRedirectSource = null; 23 | public StringSegment OutputRedirectTarget = null; 24 | public List RedirectUnions = new List(); 25 | public bool IsInputRedirected => InputRedirectSource != null || HereScript != null; 26 | public bool IsOutputRedirected => OutputRedirectTarget != null || HereScript != null; 27 | 28 | public PipelineWorkUnit() { } 29 | 30 | public PipelineWorkUnit(StringSegment stringSegment) 31 | { 32 | Segments.Add(stringSegment); 33 | StartIndex = stringSegment.X; 34 | } 35 | 36 | public override string ToString() 37 | { 38 | var redirectUnions = ""; 39 | var attributes = new string[] 40 | { 41 | CommandLineSyntax.PipelineConditionToStr(PipelineCondition), 42 | HereScript!=null?CommandLineSyntax.HereScript:null, 43 | InputRedirectSource!=null?"<":null, 44 | OutputRedirectTarget!=null?">":null, 45 | redirectUnions 46 | }; 47 | var attrs = string.Join(' ', attributes.Where(x => x != null)).Trim(); 48 | if (!string.IsNullOrWhiteSpace(attrs)) attrs = $" ({attrs})"; 49 | return $"{Darkgreen}{StartIndex}-{EndIndex}: {string.Join(' ', Segments.Select(x => x.Text))}" 50 | + attrs 51 | + ((NextUnit == null) ? "" : " " + (NextUnit == null ? "" : Br) + NextUnit.ToString()); 52 | } 53 | 54 | 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Processor/CommandEvaluationContextSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OrbitalShell.Component.CommandLine.Processor 8 | { 9 | /// 10 | /// command operation context settings 11 | /// 12 | public class CommandEvaluationContextSettings 13 | { 14 | public bool IsQuiet { get; set; } 15 | 16 | public bool HasConsole { get; set; } 17 | 18 | public bool IsInteractive { get; set; } 19 | 20 | public bool IsMute => IsQuiet || !HasConsole; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Processor/CommandLineProcessorExternalParserExtension.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | using OrbitalShell.Component.CommandLine.Parsing; 3 | 4 | namespace OrbitalShell.Component.CommandLine.Processor 5 | { 6 | public class CommandLineProcessorExternalParserExtension 7 | : IExternalParserExtension 8 | { 9 | public ICommandLineProcessor CommandLineProcessor { get; set; } 10 | 11 | /// 12 | /// this instance is not initialized (no parameter commandLineProcessor) and thus can't be used before further init 13 | /// 14 | public CommandLineProcessorExternalParserExtension() 15 | { 16 | } 17 | 18 | /*public CommandLineProcessorExternalParserExtension(ICommandLineProcessor commandLineProcessor) 19 | { 20 | CommandLineProcessor = commandLineProcessor; 21 | }*/ 22 | 23 | public bool TryGetCommandSpecificationFromExternalToken( 24 | ExternalParserExtensionContext externalParserExtensionContext, 25 | out CommandSpecification commandSpecification, 26 | out string commandPath) 27 | { 28 | commandSpecification = null; 29 | commandPath = null; 30 | 31 | // search in path in case of can delegate to os call to exec file or script 32 | if (CommandLineProcessor.ExistsInPath( 33 | externalParserExtensionContext.Context, 34 | externalParserExtensionContext.TokenName, 35 | out commandPath)) 36 | { 37 | // get the 'exec' command 38 | var execComMethodInfo = 39 | typeof(CommandLineProcessorCommands) 40 | .GetMethod(nameof(CommandLineProcessorCommands.Exec)); 41 | commandSpecification = CommandLineProcessor 42 | .ModuleManager 43 | .ModuleCommandManager 44 | .GetCommandSpecification(execComMethodInfo); 45 | 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Processor/ICommandLineProcessorSettings.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | using OrbitalShell.Component.Console; 4 | 5 | namespace OrbitalShell.Component.CommandLine.Processor 6 | { 7 | public interface ICommandLineProcessorSettings 8 | { 9 | string AppDataFolderName { get; set; } 10 | string AppDataRoamingUserFolderPath { get; } 11 | string AppEditor { get; set; } 12 | string AppLicense { get; set; } 13 | string AppLongName { get; set; } 14 | string AppName { get; set; } 15 | string AppVersion { get; set; } 16 | CommandEvaluationContext CommandEvaluationContext { get; } 17 | string CommandsAliasFileName { get; set; } 18 | string CommandsAliasFilePath { get; } 19 | string DefaultsFolderName { get; set; } 20 | string DefaultsFolderPath { get; } 21 | TextWriterWrapper Err { get; } 22 | char ErrorPositionMarker { get; set; } 23 | string InitFileName { get; set; } 24 | string HistoryFileName { get; set; } 25 | string HistoryFilePath { get; } 26 | TextReader In { get; } 27 | string KernelCommandsModuleAssemblyName { get; set; } 28 | string KernelCommandsRootNamespace { get; set; } 29 | bool LogAppendAllLinesErrorIsEnabled { get; set; } 30 | string LogFileName { get; set; } 31 | string LogFilePath { get; } 32 | string ModulesInitFileName { get; set; } 33 | string ModulesInitFilePath { get; } 34 | ConsoleTextWriterWrapper Out { get; } 35 | string PathExtInit { get; set; } 36 | bool PrintInfo { get; set; } 37 | string ShellAppDataPath { get; } 38 | string ShellExecBatchExt { get; set; } 39 | string UserProfileFileName { get; set; } 40 | string UserProfileFilePath { get; } 41 | string InitFilePath { get; } 42 | string ShellSettingsFilePath { get; } 43 | string UserSettingsFilePath { get; } 44 | 45 | void Initialize(CommandEvaluationContext commandEvaluationContext); 46 | } 47 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Processor/ICommandResult.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.CommandLine.Processor 2 | { 3 | public interface ICommandResult 4 | { 5 | object GetOuputData(); 6 | int ReturnCode { get; } 7 | string ExecErrorText { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Processor/ReturnCode.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.CommandLine.Processor 2 | { 3 | public enum ReturnCode 4 | { 5 | OK = 0, 6 | Error = 1, 7 | NotIdentified = 2, 8 | Unknown = 3 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Reader/BeginReadlnAsyncResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace OrbitalShell.Component.CommandLine.Reader 5 | { 6 | public class BeginReadlnAsyncResult : IAsyncResult 7 | { 8 | public object AsyncState { get; protected set; } 9 | 10 | public WaitHandle AsyncWaitHandle { get; protected set; } 11 | 12 | public bool CompletedSynchronously { get; protected set; } = false; 13 | 14 | public bool IsCompleted { get; protected set; } = true; 15 | 16 | public BeginReadlnAsyncResult(string line) 17 | { 18 | AsyncState = line; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Reader/ExpressionEvaluationResultCommandDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | using OrbitalShell.Component.CommandLine.Processor; 8 | 9 | namespace OrbitalShell.Component.CommandLine.Reader 10 | { 11 | public class Delegates 12 | { 13 | public delegate ExpressionEvaluationResult 14 | ExpressionEvaluationCommandDelegate( 15 | CommandEvaluationContext context, 16 | string com, 17 | int outputX, 18 | string postAnalysisPreExecOutput = null); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Reader/ICommandLineReader.cs: -------------------------------------------------------------------------------- 1 | //#define dbg 2 | using System; 3 | 4 | using OrbitalShell.Component.CommandLine.Processor; 5 | using OrbitalShell.Component.Console; 6 | 7 | namespace OrbitalShell.Component.CommandLine.Reader 8 | { 9 | public interface ICommandLineReader 10 | { 11 | IConsole Console { get; set; } 12 | Func InputProcessor { get; set; } 13 | 14 | void Initialize( 15 | string prompt = null, 16 | ICommandLineProcessor clp = null, 17 | Delegates.ExpressionEvaluationCommandDelegate evalCommandDelegate = null); 18 | int BeginReadln(AsyncCallback asyncCallback, string prompt = null, bool waitForReaderExited = true, bool loop = true); 19 | void CleanUpReadln(); 20 | string GetPrompt(); 21 | void IgnoreNextKey(); 22 | ExpressionEvaluationResult ProcessCommandLine(string commandLine, Delegates.ExpressionEvaluationCommandDelegate evalCommandDelegate, bool outputStartNextLine = false, bool enableHistory = false, bool enablePrePostComOutput = true); 23 | int ReadCommandLine(string prompt = null, bool waitForReaderExited = true); 24 | (IAsyncResult asyncResult, ExpressionEvaluationResult evalResult) SendInput(string text, bool sendEnter = true, bool alwaysWaitForReaderExited = false, Action postInputProcessorCallback = null); 25 | void SendNextInput(string text, bool sendEnter = true); 26 | void SetDefaultPrompt(string prompt); 27 | void SetPrompt(string prompt = null); 28 | void SetPrompt(CommandEvaluationContext context, string prompt); 29 | void StopBeginReadln(); 30 | void WaitReadln(); 31 | } 32 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/CommandLine/Reader/Interaction.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | using OrbitalShell.Component.Console; 3 | using System; 4 | using System.Collections.Generic; 5 | using sc = System.Console; 6 | 7 | namespace OrbitalShell.Component.CommandLine.Reader 8 | { 9 | /// 10 | /// TODO: move to Component.UI.Input 11 | /// 12 | public class Interaction 13 | { 14 | /// 15 | /// ask a question, read input to enter. returns true if input is 'y' or 'Y' 16 | /// 17 | /// 18 | /// returns true if input is 'y' or 'Y' 19 | public static bool Confirm(CommandEvaluationContext context,string question) 20 | { 21 | var r = false; 22 | void endReadln(IAsyncResult result) 23 | { 24 | r = result.AsyncState?.ToString()?.ToLower() == "y"; 25 | } 26 | var cmdlr = new CommandLineReader( ); 27 | cmdlr.Initialize(question + "? "); 28 | cmdlr.BeginReadln(endReadln, null, true, false); 29 | context.Out.Echoln(); 30 | return r; 31 | } 32 | 33 | /// 34 | /// display a bar of text that wait a text input 35 | /// 36 | /// 37 | /// 38 | /// 39 | public static object InputBar(CommandEvaluationContext context, string text, List inputMaps) 40 | { 41 | object r = null; 42 | context.Out.Echo($"{context.ShellEnv.Colors.InteractionBar}{text}{ANSI.RSTXTA}"); 43 | bool end = false; 44 | string input = ""; 45 | while (!end) 46 | { 47 | var c = sc.ReadKey(true); 48 | if (!Char.IsControl(c.KeyChar)) 49 | input += c.KeyChar; 50 | bool partialMatch = false; 51 | foreach (var inputMap in inputMaps) 52 | { 53 | var match = inputMap.Match(input, c); 54 | if (match == InputMap.ExactMatch) 55 | { 56 | r = inputMap.Code; 57 | end = true; 58 | break; 59 | } 60 | partialMatch |= match == InputMap.PartialMatch; 61 | } 62 | if (!partialMatch) input = ""; 63 | 64 | System.Diagnostics.Debug.WriteLine($"{input}"); 65 | } 66 | return r; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Console/EchoEvaluationContext.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | /// 6 | /// contextual data of an echo operation context 7 | /// 8 | public class EchoEvaluationContext 9 | { 10 | /// 11 | /// target stream 12 | /// 13 | public ConsoleTextWriterWrapper Out; 14 | 15 | /// 16 | /// command evaluation context 17 | /// 18 | public CommandEvaluationContext CommandEvaluationContext; 19 | 20 | /// 21 | /// formatting options 22 | /// 23 | public FormatingOptions Options; 24 | 25 | public EchoEvaluationContext( 26 | ConsoleTextWriterWrapper @out, 27 | CommandEvaluationContext cmdContext, 28 | FormatingOptions options = null) 29 | { 30 | Out = @out; 31 | CommandEvaluationContext = cmdContext; 32 | Options = options; 33 | } 34 | 35 | public EchoEvaluationContext(CommandEvaluationContext context) 36 | { 37 | Out = context.Out; 38 | CommandEvaluationContext = context; 39 | Options = new FormatingOptions(); 40 | } 41 | 42 | public EchoEvaluationContext( 43 | EchoEvaluationContext ctx 44 | ) 45 | { 46 | Out = ctx.Out; 47 | CommandEvaluationContext = ctx.CommandEvaluationContext; 48 | Options = ctx.Options; 49 | } 50 | 51 | public EchoEvaluationContext( 52 | EchoEvaluationContext ctx, 53 | FormatingOptions options 54 | ) 55 | { 56 | Out = ctx.Out; 57 | CommandEvaluationContext = ctx.CommandEvaluationContext; 58 | Options = options; 59 | } 60 | 61 | /// 62 | /// for Lib.TypeExt.Clone() method purpose 63 | /// 64 | public EchoEvaluationContext() { } 65 | 66 | public void Deconstruct( 67 | out ConsoleTextWriterWrapper @out, 68 | out CommandEvaluationContext context, 69 | out FormatingOptions options) 70 | { 71 | @out = Out; 72 | context = CommandEvaluationContext; 73 | options = Options; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Console/EchoPrimitiveMap.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace OrbitalShell.Component.Console 7 | { 8 | // TODO: still a draft ... 9 | public class EchoPrimitiveMap 10 | { 11 | public bool MappedCall( 12 | object obj, 13 | EchoEvaluationContext context 14 | ) 15 | { 16 | obj = obj ?? throw new NullReferenceException(); 17 | return false; 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Console/FormatingOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | public class FormatingOptions : ShellObject 6 | { 7 | static new FormatingOptions _instance; 8 | public new static FormatingOptions Instance 9 | { 10 | get 11 | { 12 | if (_instance == null) _instance = new FormatingOptions(); 13 | return _instance; 14 | } 15 | } 16 | 17 | public bool LineBreak = true; 18 | 19 | public bool IsRawModeEnabled = false; 20 | 21 | public FormatingOptions() { } 22 | 23 | public FormatingOptions(FormatingOptions o) => InitFrom(o); 24 | 25 | public FormatingOptions InitFrom(FormatingOptions o) 26 | { 27 | this.IsRawModeEnabled = o.IsRawModeEnabled; 28 | this.LineBreak = o.LineBreak; 29 | return this; 30 | } 31 | 32 | public FormatingOptions( 33 | bool lineBreak, 34 | bool isRawModeEnabled) 35 | { 36 | LineBreak = lineBreak; 37 | IsRawModeEnabled = isRawModeEnabled; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Console/IShellObject.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | 3 | namespace OrbitalShell.Component.Console 4 | { 5 | /// 6 | /// recommended but not mandatory interface of an object that might almost be displayed in the shell and used a a command parameter 7 | /// 8 | public interface IShellObject 9 | { 10 | /// 11 | /// Echo method : ouptut a formatted text display of the object into @out, eventually using the formatting options. 12 | /// must works with a given command evaluation context 13 | /// 14 | /// echo context from command eval context 15 | void Echo(EchoEvaluationContext context); 16 | 17 | /// 18 | /// returns the object as text representation of its value (the returned value might be convertible to a native value) 19 | /// this method must be in place of ToString() to provide a string value to describe the object. ToString must be reserved for debug purpose only 20 | /// 21 | /// readable value representing the object 22 | string AsText(CommandEvaluationContext context); 23 | } 24 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Console/TableFormattingOptions.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Console 2 | { 3 | public class TableFormattingOptions : FormatingOptions 4 | { 5 | public enum TableLayout 6 | { 7 | NoBorders, 8 | HeaderHorizontalSeparator, 9 | HeaderHorizontalSeparatorVerticalSeparators 10 | } 11 | 12 | public bool NoBorders = true; 13 | public bool PadLastColumn = true; 14 | public TableLayout Layout = TableLayout.HeaderHorizontalSeparator; 15 | public bool UnfoldCategories = true; 16 | public bool UnfoldItems = true; 17 | public int ColumnLeftMargin = 0; 18 | public int ColumnRightMargin = 4; 19 | 20 | public TableFormattingOptions() { } 21 | 22 | public TableFormattingOptions(FormatingOptions o) => InitFrom(o); 23 | 24 | public TableFormattingOptions(TableFormattingOptions o) 25 | { 26 | base.InitFrom(o); 27 | NoBorders = o.NoBorders; 28 | PadLastColumn = o.PadLastColumn; 29 | Layout = o.Layout; 30 | UnfoldCategories = o.UnfoldCategories; 31 | UnfoldItems = o.UnfoldItems; 32 | ColumnLeftMargin = o.ColumnLeftMargin; 33 | ColumnRightMargin = o.ColumnRightMargin; 34 | } 35 | 36 | public TableFormattingOptions( 37 | bool noBorders = true, 38 | bool padLastColumn = true, 39 | TableLayout layout = TableLayout.HeaderHorizontalSeparator, 40 | bool unfoldCategories = true, 41 | bool unfoldItems = true, 42 | int columnLeftMargin = 0, 43 | int columnRightMargin = 4) 44 | { 45 | NoBorders = noBorders; 46 | PadLastColumn = padLastColumn; 47 | Layout = layout; 48 | UnfoldCategories = unfoldCategories; 49 | UnfoldItems = unfoldItems; 50 | ColumnLeftMargin = columnLeftMargin; 51 | ColumnRightMargin = columnRightMargin; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Data/DataRegistry.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Lib; 2 | using System; 3 | using System.Collections.Generic; 4 | using static OrbitalShell.Component.Shell.Variable.VariableSyntax; 5 | 6 | namespace OrbitalShell.Component.Shell.Data 7 | { 8 | public class DataRegistry 9 | { 10 | readonly Dictionary _objects 11 | = new Dictionary(); 12 | 13 | public readonly DataObject RootObject = new DataObject("root"); 14 | 15 | public List GetDataValues() => RootObject.GetAttributes(); 16 | 17 | public void Set(string path, object value = null, bool isReadOnly = false, Type type = null) 18 | { 19 | var p = SplitPath(path); 20 | var valueObj = RootObject.Set(p, value, isReadOnly, type); 21 | if (RootObject.Get(p, out _) && !_objects.ContainsKey(path)) 22 | _objects.AddOrReplace(path, valueObj); 23 | } 24 | 25 | public void Unset(string path) 26 | { 27 | RootObject.Unset(SplitPath(path)); 28 | if (_objects.ContainsKey(path)) 29 | _objects.Remove(path); 30 | } 31 | 32 | public bool Get(string path, out object data) 33 | { 34 | if (_objects.TryGetValue(path, out var value)) 35 | { 36 | data = value; 37 | return true; 38 | } 39 | if (RootObject.Get(SplitPath(path), out var sdata)) 40 | { 41 | _objects.AddOrReplace(path, sdata); 42 | data = sdata; 43 | return true; 44 | } 45 | data = null; 46 | return false; 47 | } 48 | 49 | public bool GetPathOwner(string path, out object data) 50 | => RootObject.GetPathOwner(SplitPath(path), out data); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Data/IDataObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace OrbitalShell.Component.Shell.Data 5 | { 6 | public interface IDataObject 7 | { 8 | string Name { get; } 9 | DataObject Parent { get; set; } 10 | bool IsReadOnly { get; } 11 | bool HasAttributes { get; } 12 | 13 | List GetAttributes(); 14 | bool Get(ArraySegment path, out object data); 15 | bool GetPathOwner(ArraySegment path, out object data); 16 | bool Has(ArraySegment path, out object data); 17 | IDataObject Set(ArraySegment path, object value, bool isReadOnly = false, Type type = null); 18 | void Unset(ArraySegment path); 19 | } 20 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Defaults/.aliases: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # this file contains the user aliases definitions commands 3 | 4 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Defaults/.init: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # this is the default orbital shell init script 3 | 4 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Defaults/.profile: -------------------------------------------------------------------------------- 1 | #!orbsh 2 | # this is the default orbital shell user profile init script 3 | 4 | prompt "(rdc)> " 5 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/AggregateHookResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.Shell.Hook 4 | { 5 | public class AggregateHookResult 6 | { 7 | public readonly List<(object hook, ReturnType result)> Results 8 | = new List<(object hook, ReturnType result)>(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/HookAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OrbitalShell.Component.CommandLine; 3 | 4 | namespace OrbitalShell.Component.Shell.Hook 5 | { 6 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] 7 | public class HookAttribute : Attribute 8 | { 9 | public readonly string HookName; 10 | 11 | public HookAttribute( 12 | Hooks hookName 13 | ) 14 | { 15 | HookName = hookName + ""; 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/HookManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-Kernel/Component/Shell/Hook/HookManager.cs -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/HookSpecification.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace OrbitalShell.Component.Shell.Hook 4 | { 5 | /// 6 | /// hook specification 7 | /// 8 | public class HookSpecification 9 | { 10 | public readonly object Owner; 11 | 12 | public readonly MethodInfo Method; 13 | 14 | public string Name; 15 | 16 | public HookSpecification(string name, object owner, MethodInfo method) 17 | { 18 | Owner = owner; 19 | Method = method; 20 | Name = name; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/HookTriggerMode.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Hook 2 | { 3 | /// 4 | /// how a hook should be triggered 5 | /// 6 | public enum HookTriggerMode 7 | { 8 | FirstTimeOnly, 9 | EachTime 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/HooksAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// indicates that a class own shell hooks 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] 9 | public class HooksAttribute : Attribute 10 | { 11 | public HooksAttribute( 12 | ) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Hook/IHookManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | using OrbitalShell.Component.CommandLine.Processor; 5 | 6 | namespace OrbitalShell.Component.Shell.Hook 7 | { 8 | public interface IHookManager 9 | { 10 | AggregateHookResult InvokeHooks( 11 | CommandEvaluationContext context, 12 | Hooks name, 13 | ParameterType parameter = default, 14 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime, 15 | Action callBack = null 16 | ); 17 | 18 | AggregateHookResult InvokeHooks( 19 | CommandEvaluationContext context, 20 | string name, 21 | ParameterType parameter = default, 22 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime, 23 | Action callBack = null 24 | ); 25 | 26 | void InvokeHooks( 27 | CommandEvaluationContext context, 28 | Hooks name, 29 | ParameterType parameter = default, 30 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime, 31 | Action callBack = null 32 | ); 33 | 34 | void InvokeHooks( 35 | CommandEvaluationContext context, 36 | string name, 37 | ParameterType parameter = default, 38 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime, 39 | Action callBack = null 40 | ); 41 | 42 | void InvokeHooks( 43 | CommandEvaluationContext context, 44 | Hooks name, 45 | HookTriggerMode hookTriggerMode, 46 | Action callBack 47 | ); 48 | 49 | void InvokeHooks( 50 | CommandEvaluationContext context, 51 | string name, 52 | HookTriggerMode hookTriggerMode, 53 | Action callBack 54 | ); 55 | 56 | void InvokeHooks( 57 | CommandEvaluationContext context, 58 | Hooks name, 59 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime 60 | ); 61 | 62 | void InvokeHooks( 63 | CommandEvaluationContext context, 64 | string name, 65 | HookTriggerMode hookTriggerMode = HookTriggerMode.EachTime 66 | ); 67 | 68 | void RegisterHook(CommandEvaluationContext context, string name, MethodInfo mi); 69 | } 70 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/ICommandsAlias.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using OrbitalShell.Component.CommandLine.Processor; 4 | using OrbitalShell.Lib.FileSystem; 5 | 6 | namespace OrbitalShell.Component.Shell 7 | { 8 | public interface ICommandsAlias 9 | { 10 | IReadOnlyDictionary Aliases { get; } 11 | IReadOnlyCollection AliasNames { get; } 12 | string FileName { get; } 13 | FilePath FilePath { get; } 14 | string Folder { get; } 15 | 16 | void AddOrReplaceAlias(CommandEvaluationContext context, string name, string text); 17 | string GetAlias(string name); 18 | void Init(CommandEvaluationContext context, string folderPath, string fileName); 19 | void SaveAliases(CommandEvaluationContext context); 20 | void UnsetAlias(CommandEvaluationContext context, string name); 21 | } 22 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Init/IShellArgsOptionBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using OrbitalShell.Component.CommandLine.Processor; 4 | 5 | namespace OrbitalShell.Component.Shell.Init 6 | { 7 | public interface IShellArgsOptionBuilder 8 | { 9 | bool HasArg(ShellArg arg); 10 | ShellArgsOptionBuilder ImportSettingsFromJSon(CommandEvaluationContext context, ref List appliedArgs); 11 | ShellArgsOptionBuilder ImportSettingsFromJSonFile(CommandEvaluationContext context,string path); 12 | void SetArgs(string[] args); 13 | ShellArgValue GetArg(ShellArg arg); 14 | ShellArgsOptionBuilder SetCommandLineProcessorOptions(CommandEvaluationContext context, ref List appliedArgs); 15 | ShellArgsOptionBuilder SetShellEnvVariable(CommandEvaluationContext context, string name, string value); 16 | bool IsArg(ShellArg argSpec, string argName); 17 | ShellArgsOptionBuilder SetCommandOperationContextOptions(CommandEvaluationContext context, ref List appliedArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Init/IShellBootstrap.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | using OrbitalShell.Component.Console; 3 | 4 | namespace OrbitalShell.Component.Shell.Init 5 | { 6 | public interface IShellBootstrap 7 | { 8 | void CreateRestoreUserAliasesFile(); 9 | void CreateRestoreUserHistoryFile(); 10 | ICommandLineProcessor GetCommandLineProcessor(); 11 | void InitShellInitFolder(); 12 | void InitUserProfileFolder(); 13 | ShellBootstrap Run(); 14 | void ShellInit(string[] args, IConsole console, ICommandLineProcessorSettings settings, CommandEvaluationContext context = null); 15 | } 16 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Init/IShellServiceHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Hosting; 4 | 5 | namespace OrbitalShell.Component.Shell.Init 6 | { 7 | public interface IShellServiceHost 8 | { 9 | int RunShellServiceHost(string[] args); 10 | 11 | IShellBootstrap GetShellBootstrap(string[] args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Init/ShellArg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OrbitalShell.Component.Shell.Init 8 | { 9 | public class ShellArg 10 | { 11 | public readonly string ShortName; 12 | 13 | public readonly string LongName; 14 | 15 | public ShellArg(string shortName, string longName) 16 | { 17 | ShortName = shortName; 18 | LongName = longName; 19 | } 20 | 21 | public string ShortOpt => "-" + ShortName; 22 | 23 | public string LongOpt => "--" + LongName; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Init/ShellArgValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OrbitalShell.Component.Shell.Init 8 | { 9 | public class ShellArgValue 10 | { 11 | public readonly ShellArg ShellArg; 12 | 13 | /// 14 | /// text of the argument 15 | /// 16 | public readonly string ArgText; 17 | 18 | /// 19 | /// argument value (option parameter is applyable, else next arg in args sequence) 20 | /// 21 | public readonly string ArgValue; 22 | 23 | /// 24 | /// eventually arg index in args list 25 | /// 26 | public int ArgIndex; 27 | 28 | public ShellArgValue( 29 | ShellArg shellArg, 30 | string argText, 31 | string argValue = null 32 | ) 33 | { 34 | ShellArg = shellArg; 35 | ArgValue = argValue; 36 | ArgText = argText; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/Data/ModuleInit.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Module.Data 2 | { 3 | public class ModuleInit 4 | { 5 | public string ReadMe; 6 | public ModuleInitItem[] List; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/Data/ModuleInitItem.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Module.Data 2 | { 3 | public class ModuleInitItem 4 | { 5 | public string Path; 6 | public bool IsEnabled = true; 7 | public string LowerPackageId; 8 | public string LowerVersionId; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/Data/ModuleList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace OrbitalShell.Component.Shell.Module.Data 5 | { 6 | public class ModuleList 7 | { 8 | public List Modules 9 | = new List(); 10 | 11 | public void Merge(ModuleList modList) 12 | { 13 | foreach ( var modRef in modList.Modules ) 14 | { 15 | if (!Modules.Where(x => x.ModuleId == modRef.ModuleId).Any()) 16 | Modules.Add(modRef); 17 | } 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/Data/ModuleReference.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Module.Data 2 | { 3 | /// 4 | /// reference of a module in a repository 5 | /// 6 | public class ModuleReference 7 | { 8 | public string Type; 9 | 10 | public string ModuleId; 11 | 12 | public ModuleVersion Version 13 | => new ModuleVersion(LastKnownVersion); 14 | 15 | public string LastKnownVersion; 16 | 17 | public string Description; 18 | 19 | public ModuleReference() { } 20 | 21 | public ModuleReference( 22 | string moduleId, 23 | string version, 24 | string description) 25 | { 26 | ModuleId = moduleId; 27 | Description = description; 28 | LastKnownVersion = version; 29 | } 30 | 31 | public override string ToString() 32 | { 33 | return $"{ModuleId} - {Description} - Version = {Version}"; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/IModuleCommandManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | using OrbitalShell.Component.CommandLine.CommandModel; 6 | using OrbitalShell.Component.CommandLine.Processor; 7 | 8 | namespace OrbitalShell.Component.Shell.Module 9 | { 10 | public interface IModuleCommandManager 11 | { 12 | List AllCommands { get; } 13 | IEnumerable CommandDeclaringShortTypesNames { get; } 14 | IEnumerable CommandDeclaringTypesAssemblyQualifiedNames { get; } 15 | IEnumerable CommandDeclaringTypesNames { get; } 16 | IReadOnlyDictionary> Commands { get; } 17 | 18 | string CheckAndNormalizeCommandName(string s); 19 | string CheckAndNormalizeCommandNamespace(string[] segments); 20 | CommandSpecification GetCommandSpecification(MethodInfo commandMethodInfo); 21 | int RegisterCommandClass(CommandEvaluationContext context, Type type); 22 | int RegisterCommandClass(CommandEvaluationContext context, Type type, bool registerAsModule); 23 | void RegisterCommandClass(CommandEvaluationContext context); 24 | bool UnregisterCommand(CommandSpecification comSpec); 25 | ModuleSpecification UnregisterModuleCommands(CommandEvaluationContext context, string modulePackageId); 26 | } 27 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/IModuleManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | 4 | using OrbitalShell.Component.CommandLine.Processor; 5 | using OrbitalShell.Component.Shell.Hook; 6 | 7 | namespace OrbitalShell.Component.Shell.Module 8 | { 9 | public interface IModuleManager 10 | { 11 | IModuleCommandManager ModuleCommandManager { get; } 12 | IHookManager ModuleHookManager { get; } 13 | IReadOnlyDictionary Modules { get; } 14 | 15 | Assembly GetLoadedModuleAssembly(string path); 16 | ModuleSpecification GetModuleByLowerPackageId(string lowerPackareId); 17 | ModuleSpecification GetModuleByName(string moduleName); 18 | bool IsModuleAssemblyLoaded(string path); 19 | ModuleSpecification RegisterModule(CommandEvaluationContext context, Assembly assembly); 20 | ModuleSpecification RegisterModule(CommandEvaluationContext context, string assemblyPath); 21 | ModuleSpecification UnregisterModule(CommandEvaluationContext context, string moduleName); 22 | } 23 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleAuthorsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// declare authors of a shell module 7 | /// 8 | [AttributeUsage(AttributeTargets.Assembly)] 9 | public class ModuleAuthorsAttribute : Attribute 10 | { 11 | public readonly string[] Auhors; 12 | 13 | public ModuleAuthorsAttribute(params string[] authors) 14 | { 15 | Auhors = authors; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleDependencyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// declares a dependency to an other module 7 | /// 8 | [AttributeUsage(AttributeTargets.Assembly)] 9 | public class ModuleDependencyAttribute : Attribute 10 | { 11 | public readonly string ModuleName; 12 | public readonly string ModuleMinVersion; 13 | 14 | public ModuleDependencyAttribute(string moduleName, string moduleMinVersion) 15 | { 16 | ModuleName = moduleName; 17 | ModuleMinVersion = moduleMinVersion; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleInfo.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.Processor; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// infos about what inside the module 7 | /// 8 | public class ModuleInfo 9 | { 10 | public readonly int DeclaringTypesCount = -1; 11 | 12 | public readonly int CommandsCount = -1; 13 | 14 | public readonly int HooksCount = -1; 15 | 16 | public static ModuleInfo ModuleInfoNotDefined = new ModuleInfo(); 17 | 18 | public ModuleInfo( 19 | int declaringTypesCount, 20 | int commandsCount, 21 | int hooksCount = 0 22 | ) 23 | { 24 | DeclaringTypesCount = declaringTypesCount; 25 | CommandsCount = commandsCount; 26 | HooksCount = hooksCount; 27 | } 28 | 29 | public ModuleInfo() { } 30 | 31 | public string GetDescriptor(CommandEvaluationContext context) 32 | { 33 | var f = "" + context.ShellEnv.Colors.Log; 34 | var r = $"{f}[dt={context.ShellEnv.Colors.Numeric}{DeclaringTypesCount}{f}"; 35 | r += $",com={context.ShellEnv.Colors.Numeric}{CommandsCount}{f}"; 36 | r += $",hk={context.ShellEnv.Colors.Numeric}{HooksCount}{f}](rdc)"; 37 | return r; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleSet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | public class ModuleSet : Dictionary , IModuleSet 6 | { 7 | 8 | } 9 | 10 | public interface IModuleSet : IDictionary { } 11 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleShellMinVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// declare dependency to shell min-version 7 | /// 8 | [AttributeUsage(AttributeTargets.Assembly)] 9 | public class ModuleShellMinVersionAttribute : Attribute 10 | { 11 | public readonly string ShellMinVersion; 12 | 13 | public ModuleShellMinVersionAttribute(string shellMinVersion) 14 | { 15 | ShellMinVersion = shellMinVersion; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleSpecification.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace OrbitalShell.Component.Shell.Module 5 | { 6 | /// 7 | /// module specification 8 | /// 9 | public class ModuleSpecification 10 | { 11 | public readonly Assembly Assembly; 12 | 13 | public readonly Type Type; 14 | 15 | public readonly string Name; 16 | 17 | public readonly string Description; 18 | 19 | public readonly ModuleInfo Info; 20 | 21 | public readonly string Key; 22 | 23 | public static ModuleSpecification ModuleSpecificationNotDefined = new ModuleSpecification(); 24 | 25 | public bool IsInitialized; 26 | 27 | public ModuleSpecification( 28 | string key, 29 | string name, 30 | string description, 31 | Assembly assembly, 32 | ModuleInfo info, 33 | Type type = null) 34 | { 35 | Key = key; 36 | Name = name; 37 | Assembly = assembly; 38 | Type = type; 39 | Info = info; 40 | Description = description; 41 | } 42 | 43 | public ModuleSpecification() { } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleTargetPlateformAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OrbitalShell.Lib; 3 | 4 | namespace OrbitalShell.Component.Shell.Module 5 | { 6 | /// 7 | /// declares a dependency to an other module 8 | /// 9 | [AttributeUsage(AttributeTargets.Assembly)] 10 | public class ModuleTargetPlateformAttribute : Attribute 11 | { 12 | public readonly TargetPlatform TargetPlateform; 13 | 14 | public ModuleTargetPlateformAttribute(TargetPlatform targetPlateform) 15 | { 16 | TargetPlateform = targetPlateform; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ModuleVersion.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Module 2 | { 3 | /// 4 | /// module version 5 | /// 6 | public class ModuleVersion 7 | { 8 | public readonly string Version; 9 | 10 | public ModuleVersion(string version) 11 | { 12 | Version = version; 13 | } 14 | 15 | public override string ToString() 16 | { 17 | return Version; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/ShellModuleAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Component.Shell.Module 4 | { 5 | /// 6 | /// this attribute when applied to an assembly declares it as a shell module. Then it can take part of the shell module actions (load/unload/install/uninstall) 7 | /// 8 | [AttributeUsage(AttributeTargets.Assembly)] 9 | public class ShellModuleAttribute : Attribute 10 | { 11 | public readonly string PackageId; 12 | 13 | /// 14 | /// declare the assembly beeing a shell module having the specified package ID (must match PackageID in .csproj) 15 | /// 16 | /// 17 | public ShellModuleAttribute(string packageId) { PackageId = packageId; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Module/modules-init.json: -------------------------------------------------------------------------------- 1 | { 2 | "readme": "modules list to be loaded by the kernel on init specified by absolute path, this file is populated by 'module -i', kernel modules are excluded from this file", 3 | "list": [] 4 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Variable/ShellEnvironmentNamespace.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Variable 2 | { 3 | /// 4 | /// standard shell environment namespaces 5 | /// 6 | public enum ShellEnvironmentNamespace 7 | { 8 | /// 9 | /// os environment (underlying shell/os) 10 | /// 11 | os, 12 | 13 | /// 14 | /// shell settings 15 | /// 16 | settings, 17 | 18 | /// 19 | /// commands settings 20 | /// 21 | com, 22 | 23 | /// 24 | /// debug settings 25 | /// 26 | debug, 27 | 28 | /// 29 | /// display settings 30 | /// 31 | display, 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Variable/VariableNamespace.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Component.Shell.Variable 2 | { 3 | public enum VariableNamespace 4 | { 5 | /// 6 | /// environment (shell variables) 7 | /// 8 | env, 9 | 10 | /// 11 | /// local to the command context (user variables) 12 | /// 13 | local, 14 | 15 | /// 16 | /// global (shell variables) 17 | /// 18 | global, 19 | 20 | /// 21 | /// empty name space (shell contextual variables) 22 | /// 23 | _ 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Component/Shell/Variable/VariableSyntax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using OrbitalShell.Component.CommandLine.Parsing; 4 | using static OrbitalShell.Component.CommandLine.Parsing.CommandLineSyntax; 5 | 6 | namespace OrbitalShell.Component.Shell.Variable 7 | { 8 | public static class VariableSyntax 9 | { 10 | public static int FindEndOfVariableName(char[] text, int beginPos) 11 | { 12 | int i = beginPos; 13 | while (i < text.Length) 14 | { 15 | if (!IsVariableNameValidCharacter(text[i])) 16 | { 17 | break; 18 | } 19 | i++; 20 | } 21 | return i - 1; 22 | } 23 | 24 | public static bool IsVariableNameValidCharacter(char c) 25 | { 26 | // exclude non printable caracters & flow control caracters 27 | return c > 31 28 | // exclude top level separators 29 | && !TopLevelSeparators.Contains(c) 30 | // exclude variable delimiter 31 | && c != VariablePrefix 32 | // exclude common operators 33 | && !CommonOperators.Contains(c) 34 | ; 35 | } 36 | 37 | public static string[] SplitPath(string path) 38 | { 39 | return path?.Split(VariableNamePathSeparator); 40 | } 41 | 42 | public static string GetVariableName(string path) 43 | { 44 | if (path == null) return null; 45 | var p = SplitPath(path); 46 | if (p.Length == 0) return null; 47 | return p.Last(); 48 | } 49 | 50 | public static string GetVariableName(ArraySegment path) 51 | { 52 | if (path == null) return null; 53 | if (path.Count == 0) return null; 54 | return path.Last(); 55 | } 56 | 57 | public static bool HasValidRootNamespace(string name) 58 | { 59 | var ns = Enum.GetNames(typeof(VariableNamespace)).Select(x => x + CommandLineSyntax.VariableNamePathSeparator); 60 | foreach (var n in ns) 61 | if (name.StartsWith(n)) return true; 62 | return false; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) June 2020 franck gaspoz (franck.gaspoz@gmail.com) 2 | Licence Free MIT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the « Software »), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED « AS IS », WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------------------------------ 23 | 24 | Copyright (c) Juin 2020 franck gaspoz (franck.gaspoz@gmail.com) 25 | Licence Libre MIT 26 | 27 | L’autorisation est accordée, gracieusement, à toute personne acquérant une copie 28 | de ce logiciel et des fichiers de documentation associés (le « logiciel »), de commercialiser 29 | le logiciel sans restriction, notamment les droits d’utiliser, de copier, de modifier, 30 | de fusionner, de publier, de distribuer, de sous-licencier et / ou de vendre des copies du logiciel, 31 | ainsi que d’autoriser les personnes auxquelles la logiciel est fournie à le faire, 32 | sous réserve des conditions suivantes : 33 | 34 | La déclaration de copyright ci-dessus et la présente autorisation doivent être incluses dans 35 | toutes copies ou parties substantielles du logiciel. 36 | 37 | LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D’AUCUNE SORTE, EXPLICITE OU IMPLICITE, 38 | NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D’ADÉQUATION À UN USAGE PARTICULIER ET D’ABSENCE 39 | DE CONTREFAÇON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D’AUTEUR NE SERONT RESPONSABLES 40 | DE TOUT DOMMAGE, RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D’UN CONTRAT, 41 | D’UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE LOGICIEL OU SON UTILISATION, 42 | OU AVEC D’AUTRES ÉLÉMENTS DU LOGICIEL. -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/Data/FindCounts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Lib.Data 4 | { 5 | public class FindCounts 6 | { 7 | public int FoldersCount; 8 | public int FilesCount; 9 | public int ScannedFoldersCount; 10 | public int ScannedFilesCount; 11 | public DateTime BeginDateTime; 12 | public TimeSpan Elapsed; 13 | 14 | public FindCounts() 15 | { 16 | BeginDateTime = DateTime.Now; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/Data/PatternString.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.CommandLine.CommandModel; 2 | using static OrbitalShell.Lib.Str; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace OrbitalShell.Lib.Data 6 | { 7 | /// 8 | /// normal string or wildcard / regex string
9 | /// - has wildcard symbols ? or * -> wildcard match 10 | /// - starts with \ -> RegEx
11 | /// - else normal string (string compare) 12 | ///
13 | [CustomParameterType] 14 | public class PatternString 15 | { 16 | /// 17 | /// wrapped string 18 | /// 19 | public string Str; 20 | 21 | public PatternString(string s) 22 | { 23 | Str = s; 24 | } 25 | 26 | public bool HasWildcard() 27 | { 28 | return Str == null ? 29 | false : 30 | (Str.Contains('*') || Str.Contains('?')); 31 | } 32 | 33 | public bool IsRegEx() => (Str == null) ? false : Str.StartsWith("\\"); 34 | 35 | public bool Match(string s, bool ignoreCase = false) 36 | { 37 | if (s == null) return true; 38 | if (Str == null) return false; 39 | if (IsRegEx()) 40 | { 41 | var rgex = Str.Substring(1); 42 | // TODO: add case option to regex match 43 | return Regex.IsMatch(s, rgex); 44 | } 45 | if (HasWildcard()) 46 | return MatchWildcard(Str, s, ignoreCase); 47 | return s == Str; 48 | } 49 | 50 | public override string ToString() 51 | { 52 | return Str?.ToString(); 53 | } 54 | 55 | public static implicit operator string(PatternString ps) 56 | { 57 | return ps?.Str; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/FileSystem/DirectoryPath.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using OrbitalShell.Component.CommandLine.Processor; 4 | 5 | namespace OrbitalShell.Lib.FileSystem 6 | { 7 | /// 8 | /// directory path wrapper
9 | /// normalize path text in string conversion to use / instead of \
10 | /// supports path syntaxes :
11 | /// c:\MyDir\MyFile.txt
12 | /// c:/MyDir/MyFile.txt
13 | /// c:\MyDir\
14 | /// c:\MyDir
15 | /// c:/MyDir
16 | /// c:/MyDir/
17 | /// MyDir\MySubdir
18 | /// MyDir/MySubdir
19 | /// \\MyServer\MyShare\
20 | /// \\MyServer/MyShare/
21 | /// ~\...
22 | /// ~/...
23 | ///
24 | public class DirectoryPath : FileSystemPath 25 | { 26 | public DirectoryInfo DirectoryInfo { get; protected set; } 27 | 28 | public override long Length => 0; 29 | 30 | public DirectoryPath(string path) : base(new DirectoryInfo(path)) 31 | { 32 | DirectoryInfo = (DirectoryInfo)FileSystemInfo; 33 | } 34 | 35 | public bool IsEmpty => DirectoryInfo.EnumerateFileSystemInfos().Count() == 0; 36 | 37 | public override bool CheckExists(CommandEvaluationContext context, bool dumpError = true) 38 | { 39 | if (!DirectoryInfo.Exists) 40 | { 41 | if (dumpError) context.Errorln($"directory doesn't exists: {this}"); 42 | return false; 43 | } 44 | return true; 45 | } 46 | 47 | public override string ToString() 48 | { 49 | return UnescapePathSeparators( DirectoryInfo.FullName ); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/FileSystem/Drives.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using static OrbitalShell.Lib.Str; 5 | 6 | namespace OrbitalShell.Lib.FileSystem 7 | { 8 | public class Drives 9 | { 10 | public static string GetCurrentDriveInfo() => GetDriveInfo(Environment.CurrentDirectory,true); 11 | 12 | public static string GetDriveInfo(string path, bool printFileSystemInfo = false, string prefix = "", string postfix = "", string sep = "",int digits=0) 13 | { 14 | var rootDirectory = Path.GetPathRoot(path.ToLower()); 15 | var di = DriveInfo.GetDrives().Where(x => x.RootDirectory.FullName.ToLower() == rootDirectory).FirstOrDefault(); 16 | return (di == null) ? "?" : $"{(printFileSystemInfo?(rootDirectory+" "):"")}{HumanFormatOfSize(di.AvailableFreeSpace, digits, sep,prefix,postfix)}/{HumanFormatOfSize(di.TotalSize, digits, sep,prefix,postfix)}{(printFileSystemInfo?$"({di.DriveFormat})":"")}"; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/FileSystem/FileSystemPathFormattingOptions.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Console; 2 | namespace OrbitalShell.Lib.FileSystem 3 | { 4 | public class FileSystemPathFormattingOptions : FormatingOptions 5 | { 6 | public bool PrintAttributes = true; 7 | public bool ShortPath = false; 8 | public string Prefix = ""; 9 | public string Postfix = ""; 10 | public int PaddingRight = -1; 11 | public string LinePrefix = ""; 12 | 13 | public FileSystemPathFormattingOptions() { } 14 | 15 | public FileSystemPathFormattingOptions(FormatingOptions o) => InitFrom(o); 16 | 17 | public FileSystemPathFormattingOptions( 18 | bool printAttributes = true, 19 | bool shortPath = false, 20 | string prefix = "", 21 | string postfix = "", 22 | int paddingRight = -1, 23 | string linePrefix = "", 24 | 25 | bool lineBreak = false, 26 | bool isRawModeEnabled = false 27 | ) 28 | : base(lineBreak,isRawModeEnabled) 29 | { 30 | PrintAttributes = printAttributes; 31 | ShortPath = shortPath; 32 | Prefix = prefix; 33 | Postfix = postfix; 34 | PaddingRight = paddingRight; 35 | LinePrefix = linePrefix; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/Sys/IServiceProviderScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Lib.Sys 4 | { 5 | public interface IServiceProviderScope 6 | { 7 | IServiceProvider ServiceProvider { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/Sys/ServiceProviderScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell.Lib.Sys 4 | { 5 | public class ServiceProviderScope : IServiceProviderScope 6 | { 7 | public ServiceProviderScope(IServiceProvider serviceProvider) 8 | { 9 | ServiceProvider = serviceProvider; 10 | } 11 | 12 | public IServiceProvider ServiceProvider { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/Sys/StringWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace OrbitalShell.Lib.Sys 2 | { 3 | public class StringWrapper 4 | { 5 | public string Prefix; 6 | 7 | public string Postfix; 8 | 9 | protected string _str; 10 | 11 | public StringWrapper(string str="",string prefix="",string postfix="") { 12 | _str = str; 13 | Prefix = prefix; 14 | Postfix = postfix; 15 | } 16 | 17 | string _text => Prefix + _str + Postfix; 18 | 19 | public override string ToString() => _text; 20 | 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Lib/TypesExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace OrbitalShell.Lib 5 | { 6 | /// 7 | /// types extensions 8 | /// 9 | public static class TypesExt 10 | { 11 | public static object GetParameterDefaultValue(this MethodInfo mi, int pindex) 12 | => Activator.CreateInstance(mi.GetParameters()[pindex].ParameterType); 13 | } 14 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/ModuleInfo.cs: -------------------------------------------------------------------------------- 1 | using OrbitalShell.Component.Shell.Module; 2 | using OrbitalShell.Lib; 3 | 4 | // declare a shell module 5 | 6 | [assembly: ShellModule("OrbitalShell-Kernel")] 7 | [assembly: ModuleTargetPlateform(TargetPlatform.Any)] 8 | [assembly: ModuleShellMinVersion("1.0.9")] 9 | [assembly: ModuleAuthors("Orbital Shell team")] 10 | namespace OrbitalShell.Kernel 11 | { 12 | public class ModuleInfo { } 13 | } -------------------------------------------------------------------------------- /OrbitalShell-Kernel/Modules/read-me.txt: -------------------------------------------------------------------------------- 1 | # this folder contains the modules installed into the shell. each module has a specific folder which is the module name (mangled if necessary) 2 | -------------------------------------------------------------------------------- /OrbitalShell-Kernel/assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-Kernel/assets/robotazteque.png -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/BaseTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using OrbitalShell; 3 | using OrbitalShell.Component.CommandLine.Processor; 4 | using OrbitalShell.Component.Shell; 5 | using OrbitalShell.Component.Shell.Init; 6 | 7 | using System.Linq; 8 | 9 | namespace OrbitalShell_UnitTests 10 | { 11 | [TestClass] 12 | [TestCategory("shell init")] 13 | public class BaseTests 14 | { 15 | public static string[] DefaultShellInitArgs = "--quiet --no-console --no-interact".Split(' '); 16 | 17 | [TestMethod("starts a non interactive shell")] 18 | public void TestShellNoneInteractiveStartup() 19 | { 20 | var shellInitializer = GetInitializedShell(DefaultShellInitArgs); 21 | // no exception -> test ok 22 | } 23 | 24 | /// 25 | /// returns a shell that is initialized (user profile is loaded) 26 | /// 27 | /// shell command line arguments 28 | /// a shell initializer 29 | public static ShellBootstrap GetInitializedShell(string[] args) 30 | { 31 | var st = Program.GetShellServiceHost(args); 32 | Assert.IsNotNull(st); 33 | var si = st.GetShellBootstrap(args).Run(); 34 | Assert.IsNotNull(si); 35 | return si; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/CommandLineProcessorTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | using OrbitalShell.Component.CommandLine.Processor; 9 | 10 | namespace OrbitalShell_UnitTests 11 | { 12 | [TestClass] 13 | [TestCategory("command line processor")] 14 | public class CommandLineBehaviolarTests 15 | { 16 | [TestMethod("crash of a command")] 17 | public void CommandCrashTest() 18 | { 19 | var shell = BaseTests.GetInitializedShell(BaseTests.DefaultShellInitArgs); 20 | var clr = shell 21 | .GetCommandLineProcessor() 22 | .CommandLineReader; 23 | 24 | var (asyncResult, evalResult) = clr.SendInput("com-crash-test"); 25 | 26 | Assert.IsNotNull(evalResult.EvalError); 27 | Assert.AreEqual(evalResult.EvalResultCode, (int)ReturnCode.Error); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/CommandLineSyntaxParserTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | namespace OrbitalShell_UnitTests 9 | { 10 | [TestClass] 11 | [TestCategory("command line syntax parser")] 12 | public class CommandLineSyntaxParserTests 13 | { 14 | [TestMethod("test syntaxes for standard arguments types")] 15 | public void ArgumentSyntaxTest() 16 | { 17 | var shellInit = BaseTests.GetInitializedShell(BaseTests.DefaultShellInitArgs); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) June 2020 franck gaspoz (franck.gaspoz@gmail.com) 2 | Licence Free MIT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the « Software »), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED « AS IS », WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------------------------------ 23 | 24 | Copyright (c) Juin 2020 franck gaspoz (franck.gaspoz@gmail.com) 25 | Licence Libre MIT 26 | 27 | L’autorisation est accordée, gracieusement, à toute personne acquérant une copie 28 | de ce logiciel et des fichiers de documentation associés (le « logiciel »), de commercialiser 29 | le logiciel sans restriction, notamment les droits d’utiliser, de copier, de modifier, 30 | de fusionner, de publier, de distribuer, de sous-licencier et / ou de vendre des copies du logiciel, 31 | ainsi que d’autoriser les personnes auxquelles la logiciel est fournie à le faire, 32 | sous réserve des conditions suivantes : 33 | 34 | La déclaration de copyright ci-dessus et la présente autorisation doivent être incluses dans 35 | toutes copies ou parties substantielles du logiciel. 36 | 37 | LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D’AUCUNE SORTE, EXPLICITE OU IMPLICITE, 38 | NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D’ADÉQUATION À UN USAGE PARTICULIER ET D’ABSENCE 39 | DE CONTREFAÇON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D’AUTEUR NE SERONT RESPONSABLES 40 | DE TOUT DOMMAGE, RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D’UN CONTRAT, 41 | D’UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE LOGICIEL OU SON UTILISATION, 42 | OU AVEC D’AUTRES ÉLÉMENTS DU LOGICIEL. -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/OrbitalShell-UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | OrbitalShell_UnitTests 6 | 7 | false 8 | 9 | 10 | 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/README.md: -------------------------------------------------------------------------------- 1 | ## Orbital Shell 2 | 3 | | Orbital Shell is a multi-plateform (**windows, linux, macos, arm**) command shell (according to .Net Core supported platforms and APIs compatibilities), inspired by bash and **POSIX** recommendations.

It provides any usual bash shell feature (even if modernized) and 'user friendly' syntaxes allowing to access (get/set/call) C# objects.

Developed using **C# 8, .NET Core 3.1/Net 5 and .NET Standard 2.1** 4 | -- | -- 5 |                                             |   6 | 7 | This shell integrates the most usefull shell commands, and is intented to be extended by coding new commands or downloading new commands modules within a repository of modules. Of course it can be enterly customized by using the features integrated to the shell (scripts, functions, commands, aliases, settings, parametrization,...). Having a strong ANSI/VT-100-220-300-500 support, it provides structured and colorized display of data and information (support of ASCII, Unicode and 24 bits colors). 8 | 9 | ## About the project 10 | 11 | Find any information and documentation about this project on the project's Web Site @ [Orbital SHell Git-Pages](https://orbitalshell.github.io/Orbital-Shell/) 12 | 13 | Developers and users manuals are available in the project web site @ [Orbital SHell Git-Pages (documentation)](https://orbitalshell.github.io/OrbitalShell/documentation) 14 | 15 | > [![licence mit](https://img.shields.io/badge/licence-MIT-blue.svg)](license) This project is licensed under the terms of the MIT license: [LICENSE](LICENSE) 16 | 17 | > project repositories status:
18 | ![orbital-shell](https://img.shields.io/badge/Orbital--Shell-repository-lightgrey?style=plastic) 19 | ![last commit](https://img.shields.io/github/last-commit/orbitalshell/Orbital-Shell?style=plastic) 20 | ![version](https://img.shields.io/github/v/tag/orbitalshell/Orbital-Shell?style=plastic) 21 | -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/assets/robotazteque.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-UnitTests/assets/robotazteque.ico -------------------------------------------------------------------------------- /OrbitalShell-UnitTests/assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/OrbitalShell-UnitTests/assets/robotazteque.png -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Controllers/ShellController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | using OrbitalShell_WebAPI.Models; 9 | 10 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 11 | 12 | namespace OrbitalShell_WebAPI.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | [ApiController] 16 | public class ShellController : ControllerBase 17 | { 18 | // GET: api/ 19 | [HttpGet] 20 | public ShellExecResult Get() 21 | { 22 | return ShellExecResult.EmptyShellExecResult; 23 | } 24 | 25 | // GET api//5 26 | /*[HttpGet("{id}")] 27 | public ShellExecResult Get(int id) 28 | { 29 | return ShellExecResult.EmptyShellExecResult; 30 | }*/ 31 | 32 | // POST api/ 33 | [HttpPost] 34 | public ShellExecResult Post([FromBody] string commandLine) 35 | { 36 | return ShellExecResult.EmptyShellExecResult; 37 | } 38 | 39 | // PUT api//5 40 | /*[HttpPut("{id}")] 41 | public ShellExecResult Put(int id, [FromBody] string value) 42 | { 43 | return ShellExecResult.EmptyShellExecResult; 44 | }*/ 45 | 46 | // DELETE api//5 47 | /*[HttpDelete("{id}")] 48 | public ShellExecResult Delete(int id) 49 | { 50 | return ShellExecResult.EmptyShellExecResult; 51 | }*/ 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace OrbitalShell_WebAPI.Controllers 10 | { 11 | [ApiController] 12 | [Route("[controller]")] 13 | public class WeatherForecastController : ControllerBase 14 | { 15 | private static readonly string[] Summaries = new[] 16 | { 17 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 18 | }; 19 | 20 | private readonly ILogger _logger; 21 | 22 | public WeatherForecastController(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | [HttpGet] 28 | public IEnumerable Get() 29 | { 30 | var rng = new Random(); 31 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 32 | { 33 | Date = DateTime.Now.AddDays(index), 34 | TemperatureC = rng.Next(-20, 55), 35 | Summary = Summaries[rng.Next(Summaries.Length)] 36 | }) 37 | .ToArray(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Models/ShellExecResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace OrbitalShell_WebAPI.Models 7 | { 8 | public class ShellExecResult 9 | { 10 | static ShellExecResult _EmptyShellExecResult = null; 11 | public static ShellExecResult EmptyShellExecResult 12 | { 13 | get 14 | { 15 | if (_EmptyShellExecResult == null) 16 | _EmptyShellExecResult = new ShellExecResult(); 17 | return _EmptyShellExecResult; 18 | } 19 | } 20 | 21 | public string StdOut { get; set; } = String.Empty; 22 | 23 | public string StdErr { get; set; } = String.Empty; 24 | 25 | public int ReturnCode { get; set; } = 0; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Models/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OrbitalShell_WebAPI 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/OrbitalShell-WebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | OrbitalShell_WebAPI 6 | 7 | 8 | 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace OrbitalShell_WebAPI 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IHostBuilder CreateHostBuilder(string[] args) => 21 | Host.CreateDefaultBuilder(args) 22 | .ConfigureWebHostDefaults(webBuilder => 23 | { 24 | webBuilder.UseStartup(); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:41629", 8 | "sslPort": 44362 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "OrbitalShell_WebAPI": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": "true", 23 | "launchBrowser": true, 24 | "launchUrl": "swagger", 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.HttpsPolicy; 9 | using Microsoft.AspNetCore.Mvc; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Hosting; 13 | using Microsoft.Extensions.Logging; 14 | using Microsoft.OpenApi.Models; 15 | 16 | namespace OrbitalShell_WebAPI 17 | { 18 | public class Startup 19 | { 20 | public Startup(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | } 24 | 25 | public IConfiguration Configuration { get; } 26 | 27 | // This method gets called by the runtime. Use this method to add services to the container. 28 | public void ConfigureServices(IServiceCollection services) 29 | { 30 | 31 | services.AddControllers(); 32 | services.AddSwaggerGen(c => 33 | { 34 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "OrbitalShell_WebAPI", Version = "v1" }); 35 | }); 36 | } 37 | 38 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 39 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 40 | { 41 | if (env.IsDevelopment()) 42 | { 43 | app.UseDeveloperExceptionPage(); 44 | app.UseSwagger(); 45 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "OrbitalShell_WebAPI v1")); 46 | } 47 | 48 | app.UseHttpsRedirection(); 49 | 50 | app.UseRouting(); 51 | 52 | app.UseAuthorization(); 53 | 54 | app.UseEndpoints(endpoints => 55 | { 56 | endpoints.MapControllers(); 57 | }); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OrbitalShell-WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /assets/2021-02-12 03_47_28-Window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/2021-02-12 03_47_28-Window.png -------------------------------------------------------------------------------- /assets/2021-02-12 14_28_35-Window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/2021-02-12 14_28_35-Window.png -------------------------------------------------------------------------------- /assets/orbital-shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/orbital-shell.png -------------------------------------------------------------------------------- /assets/pegi46small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/pegi46small.png -------------------------------------------------------------------------------- /assets/robotazteque.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/robotazteque.png -------------------------------------------------------------------------------- /assets/shell-wt-1.0.8-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/shell-wt-1.0.8-2.png -------------------------------------------------------------------------------- /assets/tra4brains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrbitalShell/Orbital-Shell/c9933a3894b9e79a11dca3fa4122c96c6715467a/assets/tra4brains.png -------------------------------------------------------------------------------- /deploy/docker/Dockerfile-ubuntu-latest: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | MAINTAINER Yobatman38 < yobatman [ at ] gmail.com > 3 | 4 | COPY OrbitalShell-CLI/bin/Debug/net5.0/ /home/orbsh/ 5 | RUN apt-get update \ 6 | && apt-get install -y apt-transport-https wget \ 7 | && apt autoclean \ 8 | && apt clean \ 9 | && apt autoremove --purge \ 10 | && rm -rf /var/lib/apt/lists/* 11 | 12 | RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O /root/packages-microsoft-prod.deb \ 13 | && dpkg -i /root/packages-microsoft-prod.deb \ 14 | && rm /root/packages-microsoft-prod.deb \ 15 | && apt-get update \ 16 | && apt-get install -y dotnet-runtime-5.0 \ 17 | && chmod +x /home/orbsh/orbsh \ 18 | && apt autoclean \ 19 | && apt clean \ 20 | && apt autoremove --purge \ 21 | && rm -rf /var/lib/apt/lists/* 22 | 23 | ENV PATH="/home/orbsh:${PATH}" 24 | 25 | ENTRYPOINT ["/home/orbsh/orbsh"] 26 | -------------------------------------------------------------------------------- /deploy/docker/Dockerfile-windows-latest: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/runtime:5.0 2 | MAINTAINER Yobatman38 < yobatman [ at ] gmail.com > 3 | 4 | COPY OrbitalShell-CLI/bin/Debug/net5.0/ App/ 5 | WORKDIR /App 6 | ENTRYPOINT ["dotnet", "NetCore.Docker.dll"] 7 | -------------------------------------------------------------------------------- /deploy/docker/readme.md: -------------------------------------------------------------------------------- 1 | URL of the Docker Orbital-Shell repository : 2 | 3 | https://hub.docker.com/repository/docker/orbitalshell/orbital-shell 4 | 5 | ## To run an Orbital-Shell container : 6 | 7 | ```shell 8 | $ docker run -ti --rm --name OrbitalShell orbitalshell/orbital-shell:ubuntu-latest 9 | ``` 10 | -------------------------------------------------------------------------------- /deploy/installer/linux/orbsh_installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Orbital Shell Linux Installer 4 | # by Yobatman38 - < yobatman [ at ] gmail.com > 5 | # Licensed under the MIT license. 6 | 7 | 8 | ## Config 9 | DISTRIB="debian" 10 | VERSION="10" 11 | 12 | APP_PATH="/usr/local" 13 | APP_NAME="Orbital-Shell" 14 | BUILD_PATH="OrbitalShell-CLI/bin/Debug/net5.0" 15 | 16 | 17 | ## Main script 18 | echo -e "### Orbital Shell Linux Installer" 19 | if [[ $EUID -ne 0 ]]; then 20 | echo "This script must be run as root" 1>&2 21 | exit 1 22 | fi 23 | 24 | if [[ -d "/usr/local/Orbital-Shell" ]]; then 25 | rm -R ${APP_PATH}/${APP_NAME} 26 | fi 27 | 28 | mkdir -p ${APP_PATH}/${APP_NAME} 29 | cd ${APP_PATH}/${APP_NAME} 30 | 31 | echo -e "\n--> Configure Microsoft key in APT repository" 32 | wget https://packages.microsoft.com/config/${DISTRIB}/${VERSION}/packages-microsoft-prod.deb -O packages-microsoft-prod.deb 33 | dpkg -i packages-microsoft-prod.deb 34 | rm packages-microsoft-prod.deb 35 | 36 | echo -e "\n--> Update Linux" 37 | apt-get update 38 | 39 | echo -e "\n--> Install Linux Packages" 40 | apt-get install -y apt-transport-https git dotnet-sdk-5.0 dotnet-runtime-5.0 41 | 42 | echo -e "\n--> Get Orbital-Shell" 43 | cd ${APP_PATH} 44 | git clone https://github.com/OrbitalShell/Orbital-Shell.git 45 | 46 | echo -e "\n--> Build Orbital Shell" 47 | dotnet build ${APP_PATH}/${APP_NAME}/OrbitalShell.sln 48 | chmod +x ${APP_PATH}/${APP_NAME}/${BUILD_PATH}/orbsh 49 | 50 | if [[ -h "/bin/orbsh" ]]; then 51 | rm /bin/orbsh 52 | fi 53 | 54 | ln -s ${APP_PATH}/${APP_NAME}/${BUILD_PATH}/orbsh /bin/orbsh 55 | 56 | echo -e "\n--> Run Orbital-Shell" 57 | orbsh 58 | -------------------------------------------------------------------------------- /deploy/installer/linux/readme.md: -------------------------------------------------------------------------------- 1 | To run orbsh_installer.sh, you should do the following steps. 2 | 3 | 1. Configure the vars in the script's "Config" section, as for example : 4 | DISTRIB="debian" # Or ubuntu, alpine and so on... 5 | VERSION="10" # and their version 6 | 7 | APP_PATH="/usr/local" 8 | APP_NAME="Orbital-Shell" 9 | BUILD_PATH="OrbitalShell-CLI/bin/Debug/netcoreapp3.1" 10 | 11 | 2. Run the script : 12 | sudo ./orbh_installer.sh -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | the project site has moved... 2 | 3 | [here](https://orbitalshell.github.io/OrbitalShell/) 4 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker -------------------------------------------------------------------------------- /module-index-repository/module-list.json: -------------------------------------------------------------------------------- 1 | // this is the a list of orbital shell modules that have been registered into this module repository 2 | // one line = item type; a nuget package name that designs a shell module nuget package ; [ last knonwn version ] ; description 3 | 4 | { 5 | "Modules": 6 | [ 7 | { 8 | "type": "m", 9 | "moduleId": "OrbitalShell-Module-DoomFireAlgo", 10 | "isKernelModule": false, 11 | "description": "a simple module for orbital shell that add a command running the famous doom fire algorithm (C# ANSI version)", 12 | "lastKnownVersion": "1.1.1" 13 | }, 14 | { 15 | "type": "m", 16 | "moduleId": "OrbitalShell-Module-PromptGitInfo", 17 | "isKernelModule": false, 18 | "description": "Prompt git info adds infos about git repository to the orbital shell command line prompt", 19 | "lastKnownVersion": "1.0.11" 20 | }, 21 | { 22 | "type": "m", 23 | "moduleId": "OrbitalShell-Kernel", 24 | "isKernelModule": false, 25 | "description": "Orbital Shell kernel - Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core", 26 | "lastKnownVersion": "1.0.7" 27 | }, 28 | { 29 | "type": "m", 30 | "moduleId": "OrbitalShell-Kernel-Commands", 31 | "isKernelModule": false, 32 | "description": "Orbital Shell kernel commands module", 33 | "lastKnownVersion": "1.0.7" 34 | } 35 | ] 36 | 37 | } 38 | -------------------------------------------------------------------------------- /module-index-repository/readme.txt: -------------------------------------------------------------------------------- 1 | this is a module and packages repository for orbital 🇸hell 2 | conventions to use for using this 'repo' : 3 | * may store nuget packages generated localy 4 | * provide a list of availables modules (nuget urls) : module-list 5 | --------------------------------------------------------------------------------