Giter VIP home page Giter VIP logo

orbitalshell / orbital-shell Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 5.0 16.5 MB

Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# NET 5.0

Home Page: https://orbitalshell.github.io/Orbital-Shell/

License: MIT License

C# 98.80% Shell 1.20%
linux shell bash cli csharp interactive command-line-tool command-line-tools command-line-parser command-line-interface

orbital-shell's Introduction

Orbital Shell

Orbital Shell is a multi-platform (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 5.0 - compatible with modules and libraries targeting .NET Core 3.1 and .NET Standard 2.1



.NET last commit releasever releasedate
openi closei closei closei
toplanguage lngcount
codesize reposize
licence mit

NuGet packages

package ID type NuGet verion ID
libraries
OrbitalShell-ConsoleApp
OrbitalShell-Kernel
OrbitalShell-Kernel-Commands
net5.0 classlib
net5.0 classlib
net5.0 classlib

NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads

modules
OrbitalShell-PromptGitInfo
OrbitalShell-DoomFireAlgo
shell module (net5.0)
shell module (net5.0)

NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads

binaries
OrbitalShell
OrbitalShell-win-x64
OrbitalShell-linux-musl-x64
OrbitalShell-linux-x64
OrbitalShell-linux-arm
OrbitalShell-linux-arm64
OrbitalShell-osx-x64
CLI any dotnet platform*
CLI WIN x86
CLI linux MUSL x64
CLI linux x64
CLI linux ARM
CLI linux ARM x64
CLI OSX x64

NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads
NuGetVersion NuGetDownloads

Docker images

image ID description link
orbitalshell/orbital-shell Linux Ubuntu amd64 https://hub.docker.com/r/orbitalshell/orbital-shell

About the project

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 entirely 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).

Find any information and documentation about this project on the project's Web Site @ Orbital SHell Git-Pages

                     

Developers and users manuals are available in the project web site @ Orbital SHell Git-Pages (documentation)


Contribute !

😄 We are looking for collaborators 👯 to help for evolving this tool ! If you like the command line, the bash syntax, programming cli tools, parsers, data streams, ANSI, C# 8, batch, and so on... you may like to develop orbital shell! Any idea, suggest, code, feedback is welcomed ! You can directly FORK the project @ https://github.com/OrbitalShell/Orbital-Shell.git and start developing to prepare your first pull request, it will be well received. You can also peek an issue and start working on. Join the orbital shell team and get advantages of the team tools on github. We can contact 💬 by mail, skype and so on...

You can directly FORK the project @ https://github.com/OrbitalShell/Orbital-Shell.git and start developing to prepare your first pull request, it will be well received. You can also peek an issue and start working on.

Join the orbital shell team and get advantages of the team tools on github. We can contact 💬 by mail, skype and so on...

Join the project:

⏩ ⏩ Join the project. You can send a mail to the project team @ mailto://[email protected] or to the maintener me

  • Curious / beginner / intermediate / expert are all welcomed!
  • A simple hello from you part and you will be welcomed and invited to join the project 👍 !
  • A simple star on the project main repo and you will also be invited 👋 !

⏩ ⏩ This project is a collaborative work, any one can participate and do anything he wishes 😎 !

There are a various subjects that can be treated:

  • .NET 5.0 (C# 8) programming
  • develop command line parser
  • develop shell commands (find,ls,grep,sed,..: add/improve any command you want!)
  • develop shell scripts (.orbsh/.sh)
  • Technical documentation
  • Automated Tests
  • Code review / validation of pull requests
  • Design any new feature
  • CI/CD (powered by GitHub workflows)
  • build binaries / distribs / .nupkg / setups / ...
  • Web site development (design, content update, ...)
  • Internationalization
  • Translates

The project team like to meet people and wish to share pleasure of programming and technology enthusiasm, with fun and good spirit



Features

a view of the shell running in Windows Terminal


  • Is a 'bash style' POSIX command shell
    done
  • The modules that are integrated into the shell provide the most usefull shell commands (ls/dir,rm,mv,cp,find,echo,clear,more,env,set,export,history,alias,...), tests commands, text editor command, and so on... , covering the fields of file system,text files,console output, data management, user input
    • modules can contains any item that the shell is intended to handle: commands, hooks, scripts/functions, settings, help, doc, assets, ...
      done
    • dedicated repositories are used to get known modules list
      done
    • modules are versioned and delivered throught nupkg packets, currently hosted at NuGet
      done
    • modules are installed into the binaries of the shell
      done issue
    • modules to be loaded are loaded by the shell kernel on user session startup
      done issue
  • The shell command engine implements:
    • A command line reader with:

      • usual input keyboard shortcuts
        done issue
      • auto completion
        todoissue
      • input feedback (colorization)
        todo issue
    • Streams standard input (stdIn), standard output (stdOut), and standard error (StdErr)
      done

    • Streams redirections ( < > )
      uncompleteissue

    • pipelines of commands:

      • sequences of commands ( | ) and conditional sequences of commands ( &&, || )
        uncompleteissue
      • groups of commands ( .. ; .. )
        todoissue
      • background execution ( & )
        todoissue
      • commands return a result code and can returns values
        done
        • When returning values and when specified, a pipe ( | ) between commands can pass objects instead of streams
          uncompleteissue
    • Cancellation of commands execution Task (Ctrl-Z)
      done

    • Batches of commands (scripts)

      • traditional batch of shell commands (.sh,.orbsh)
        uncompleteissue
      • C# language scripts (.cssh)
        todoissue
    • Variables

      • Variables can store any data of any C# object type
        • The command line syntax has been extended to support an object notation to indicate accessing an object member or invoking an object method
          uncompleteissue
        • Integrates the os shell environment variables (with type String)
          done
        • Are getted and setted with $ (in any command arg), set and =
          uncompleteissue
      • Functions can be defined by a shell script or by a C# compiled source
        todoissue
      • Aliases for command names
        done
      • Shell environment : the shell initialization feature deploy and setup a shell environment for the current user (profile folder and initialization scripts: .profile,.alias,.history,.orbsh)
        done
    • Extensibility:

      • The default command line grammar can be changed to get other syntaxes (zsh, DOS,...) or a new one
        done
      • The command line engine can be overriden and extended to enhance the existing features (auto complete inputs,parsing inputs,running commands,...)
        done
      • A simple way to define shell commands using C# method and parameters attributes, avoiding the developer to handle syntax analyzing and shell integration (command help, pipelines, standard stream redirections) councerns, allowing to support either simple values types (int,float,string,date time,..) and object types (even generic collection), and that can interacts together and with the shell throught data objects
        done
      // a Unix rm command implementation:
      [Command("remove file(s) and/or the directory(ies)")]
      public 
          CommandResult<(List<FileSystemPath> items, FindCounts counts)> 
          Rm(
              CommandEvaluationContext context,
              [Parameter("file or folder path")] WildcardFilePath path,
              [Option("r", "recurse", "also remove files and folders in sub directories")] bool recurse,
              [Option("i", "interactive", "prompt before any removal")] bool interactive,
              [Option("v", "verbose", "explain what is being done")] bool verbose,
              [Option("e", "delete-empty", "remove empty directories")] bool rmEmptyDirs,
              [Option("s", "short", "short display: do not print file system attributes when verbose")] bool noattributes,
              [Option("m", "simulate", "don't remove any file/or folder, just simulate the operation (enable verbose)")] bool simulate
          )
      {
          var r = new List<FileSystemPath>();
          var counts = new FindCounts();
          if (path.CheckExists(context))
          {
              var items = FindItems(context, path.FullName, path.WildCardFileName ?? "*", !recurse, true, false, !noattributes, !recurse, null, false, counts, false, false);
              
              /* ... */
              
              return new CommandResult<(List<FileSystemPath>, FindCounts)>((r, counts), ReturnCode.OK);
          }
          else
              return new CommandResult<(List<FileSystemPath>, FindCounts)>((r, counts), ReturnCode.Error);
      }
    • such a command will be auto documented like this by the shell help command:


Orbital shell uses these libraries:

  • Microsoft.CodeAnalysis.CSharp.Scripting
  • Microsoft.Extensions.ObjectPool
  • Microsoft.Extensions.Hosting
  • NewtonSoft.Json

notice / caveat

The project orbital shell was dependent of the project DotNetConsoleAppToolkit. Now the library DotNetConsoleAppToolkit project repository is ARCHIVED since it has been integrated into the orbital-shell project repository as project OrbitalShell-ConsoleApp, so it is still under development but code has been moved to this repository dot-net-console-app-toolkit last commit version

⚠️ this project might be considered as a toy for old developer



Warning: due to the average age of our main contributors, this project might contains vintage architecture,design and code. Nevertheless the source code is intensively based on young devs preferred patterns, C# 8 language usage (intellisense agrees), and it pretends to fit to good practices and architecture guidelines.

orbital-shell's People

Contributors

franck-gaspoz avatar satinwukerorig avatar yobatman38 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

orbital-shell's Issues

background execution ( & )

add syntax:
commandName commandArgs &
and do not wait end of exec (current case) for respecting consign &

command alias should respect bash posix

command alias should respect bash posix

currently

alias {aliasName} {aliasText} 

Expected

alias {aliasExpression} 

with alias expression := aliasName = aliasText

issue

variables are substituted because they appears in a command parameter string ... it would be better if the substitution of variables is avoid in that case, thus the evaluation of parameters can be done when executing the alias text, otherwise the substitution is done twice (actual case)

auto complete with TAB at command line reader input

auto complete with TAB at command line reader input

needs a thesaurus of words provided by the kernel and any component that contains known words classified by category. the command line parser must provides the word category

C# language scripts (.cssh)

like c# functions supported by the shell, we could run special batch of c# script.
simply share the CommandEvaluationContext, add supports for standards libs, add declaration of supplementary lib imports and runs the script in the c# script engine

Hooks that may be triggered several times could lead to unexpected module behavior

Describe the bug
Hooks that may be triggered several times could lead to unexpected module behavior 💣💣💣💣 : generally hooks crash and module isn't loaded. module loading chain is not canceled.

To Reproduce
load twice modules with:

> module -i {modulePath}

Expected behavior
hooks like MODULE INIT should not be triggered several times. Module should not have to handle this

$_./ doesn't works ... others special vars with single car behind _. also

was thinking of a default in variable name parser, but seems it is just a lake of variable name searching in namespaces, like if the _ namespace if never scanned by search var function.
see the code:

OrbitalShell-Kernel/Component/Shell/Variable/Variables.cs

/// <summary>
/// search in variables the path according to these precedence rules:
/// - absolute path
/// - path related to Local
/// - path related to Env
/// - path related to Global
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public bool Get(string path, out object value, bool throwException = true)
{
    var r = _dataRegistry.Get(path, out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.local, path), out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.global, path), out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.env, path), out value);
    if (!r && throwException)
        throw new VariablePathNotFoundException(path);
    return r;
}

there is no search in:

VariableNamespace._

what is strange is that search in absolute path failed for _.{..}

to reproduce:

> echo $_./

⚠️ the use of caracter '_' should be a source of councerns since it is also used as namespace separator encoding in Enums that define variables namespaces and names

Keyboard Shortcut Support Issue

Describe the bug
The shortcuts is not supported completely. (like Control+C)

To Reproduce

  1. ssh xxx@xxx
  2. if ssh is waiting for response, Control-C will not work,

Expected behavior
Control-C works

Desktop (please complete the following information):

  • OS: Windows 10 Pro

fix kernel architecture weaks (remove static classes, add dependency injection, eventually interfaces for dis-coupling and modularity)

example of need of DI: see

        /// <summary>
        /// register a kernel-hook
        /// </summary>
        /// <param name="context">command evaluation context</param>
        /// <param name="mi">hook method info</param>
        public void RegisterHook(
            CommandEvaluationContext context,
            string name,

            MethodInfo mi)
        {
            object owner = _GetInstance(mi.DeclaringType);      // TODO: having no instance, we MUST use DI to share INSTANCES
            var hs = new HookSpecification(name, owner, mi);
            _hooks.AddOrReplace(name, hs);
        }

👁️ https://github.com/OrbitalShell/Orbital-Shell/blob/master/OrbitalShell-Kernel/Component/Shell/Module/ModuleHookManager.cs

groups of commands ( .. ; .. )

implements syntax in command line parser and link to existing grouping of commands in command line processor.
syntax is ( command1 args1 ; ... ; commandn argsn )

Streams redirections ( < > )

implements support of streams redirects in command line.
partially implemented. needs to be completed. related to pipeline processor (pp)

traditional batch of shell commands (.sh,.orbsh)

implementation is incomplete regarding to:

  • env not correctly initialized : a sub shell must be prepared to run the batch (that is the same for running any command)
  • batch args not transmitted to the batch env
  • instructional commands missing: if,else,test,...

The rm command does'nt works properly at all

The rm command does'nt works properly at all
stupid erros coz try to delete several times the same items + few less rights in windows terminal/any debugger (manifest should elevate privileges but seems to not be supported in .net core)

To Reproduce

> mkdir folderName
> rm folderName -r -v

💥 🔎 the folder is not erased

if not empty:

removed drw--- Feb 19 14:33 C:/Users/franc/Documents/ORBITAL-SHELL/myrep/folder
One or more errors occurred. (Could not find a part of the path 'C:\Users\franc\Documents\ORBITAL-SHELL\myrep\folder\hello world.txt'.)

💥 🔎 files and sub-folders deleted, but folder is not erased

Expected behavior
no error, anything deleted

context

the complemented is implemented in:

https://github.com/OrbitalShell/Orbital-Shell/blob/master/OrbitalShell-Kernel-Commands/Commands/FileSystem/FileSystemCommands.cs

up and arrows keys doesn't works on linux in clr

linux deploy (thanks to @Yobatman38) : up and down arrows doesn't works in clr (command line reader)

Expected behavior
move in command history, that should be output just after the prompt, clearing any previous input/output

Desktop:

  • OS: linux
  • Version: Linux 5.4.0.65-generic (Unbuntu SMP)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.