Giter Site home page Giter Site logo

endo's People

Contributors

christianparpart avatar yaraslaut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

endo's Issues

aliases

Very often when trying to compile different projects i need to set some cmake flags that are specific to this project.
fish in that regard is quite good at path sensitive command completion but issue when i have different configuration for the same project, one of the solution that provided by cmake itself is user defined presets they are good if you are working with one project for long time but not very convenient when you just started development.
what would be nice is to have possibility to create aliases for the commands for given directory, something like :

cmake --build build --target clean && cmake --build build >> clean-build
will create alias for this directory (or global one) that will execute this command when typing
clean-build

While this can be archived by creating custom functions that will depend on directory and I use it at the moment with fish, issue that I have is that i want to have one configuration for different machines and then i need to distinguish in this function directories and host machines that i am using, so creation of such alliases directly from the shell can make it much easier.
as an example of this function for kokkos that i have in my fish function

    case "kokkos"
         if test $name = "bahamankolibri.lin.tuni.fi"
            set EXTRA -DKokkos_ARCH_TURING75=ON
         end
	 $EXTRA
         switch $argv
         case "cuda"
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=OFF \
              -D Kokkos_ENABLE_CUDA=ON \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
         case "serial"
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=ON \
              -D Kokkos_ENABLE_CUDA=OFF \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
        case '*'
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=ON \
              -D Kokkos_ENABLE_CUDA=ON \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
        end

Where CXX and CC variables depend on host machine.

Another example is long cmake command for some projects, for example
cmake -S . -B build -G Ninja -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -DLLVM_DIR=/home/yaraslau/.local/lib/cmake/llvm -D LLVM_EXTERNAL_LIT=/home/yaraslau/repo/llvm-project/build/bin/llvm-lit -DCUDAQ_BUILD_TESTS=ON -DCUDA Q_ENABLE_PYTHON=ON -D CMAKE_INSTALL_PREFIX=/home/yaraslau/.local -D CUDAQ_SKIP_MPI=ON -D CUDAQ_BUILD_TESTS=ON
or
cmake -S llvm -B build -G Ninja -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb;mlir;llvm" -D CMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=2 -D LLVM_ENABLE_RUNTIMES=all -DCMAKE_INSTALL_PR EFIX=/home/yaraslau/.local -DLLVM_INSTALL_UTILS=ON

variable substitution `$var` and `${var}`

support variable substitution

when declaring a variable like

set foo bar

then it should be able to be used when parsing a statement again, like:

some-command $foo

but also within strings itself

echo "Hello $foo."

It may make sense to support variable substitution in the bash-like syntax as well: ${variable_name}.

We should not yet think about supporting extended just yet (e.g. ${foo:-bar} etc)

support data pipelining `|>`

The |> operator (inspired from F# / Ocaml) would have the left hand side's stdout split into lines, and feed each line from left into a newly spawned process into the right.

echo "A \n B \n C" |> echo

would result into 3 echo processes, each receiving the parameter A, B, and C individually, resulting into the output:

A
B
C

That can then be chained into multiple, like in this example:

get_numbers |> times_two |> plus_one |> echo

where get_numbers prints N numbers (one per line), and times_two gets invoked N times and multiplies each number by 2, and plus_one gets invoked N times and adds 1 over the intermediate result, to then have each result printed, once per line.

notes

this is similar to what xargs -n1 does, but this syntactic shougar would not need to spawn the process xargs and have it more platform independant (e.g. xargs would not exist on Windows).

The syntax could make the code look more readable / maintainable as well.

support function syntax

Now it's getting interesting. Because we first need to figure out how we want to be able to declare a function.

I've let go of the idea to be bash-compatible, i.e. I do understand why fish shell decided to deviate here and there.

I very much like the way of how F# declares a function as well as strong typing. I think it might make sense to embrace strong typing in a shell as well. Even bash kind-of(?) does know about whether it deals with ints (for arithmetic) for example. Going explicit with types should improve readability and maintainability of scripts as well.

Syntax proposal by example:

// Define function f, receiving 3 string parameters, and returning one string
let f (a, b, c): str =
    echo "a: $a, b: $b, c: $c"
    return "($a,$b,$c)"

let y = f "foo" 3.1415 $VAR      // prints and returns something into $y
echo $y                          // prints "(foo,3.1415,VALUE)"

let g a b: str =
    echo "a is: $a, and b is: $b"
    if a = b then
        return "same"
    else
        return "not same"

let has_var name: bool =
    return (getenv $name) != ""

// single-line function definition
let has_var name: bool = (getenv $name) != ""

support process substitution `<(cmd)` and `>(cmd)`

support bash-like process substitution

syntax

<(command)

>(command)

From the bash man-page:

Process Substitution
    Process  substitution  allows  a  process's  input or output to be 
    referred to using a filename.  It takes the form of <(list) or >(list). 
    The process list is run asynchronously, and its input or output appears 
    as a filename.  This filename is passed  as  an    
    argument  to  the  current command as the result of the expansion.  
    If the >(list) form is used, writing to the file will provide    
    input for list.  If the <(list) form is used, the file passed as an 
    argument should  be  read  to  obtain  the  output  of  list.    
    Process substitution is supported on systems that support named pipes
    (FIFOs) or the /dev/fd method of naming open files.

    When available, process substitution is performed simultaneously with 
    parameter and variable expansion, command substitution, 
    and arithmetic expansion.

initial LSP mode support

The initial version should be very basic and start with the obviously most useful things that would directly affect the user:

  • language diagnostics
  • syntax highlighting
  • semantic symbol highlighting
  • hover tooltips

The LSP mode can be triggered standalone by calling endo --lsp to serve over stdio.

The LSP mode must also be used by endo's input prompt to provide syntax highlighting and realtime language diagnostics etc.

More features that are provided by the LSP protocol (and do make sense for a shell language) may come in future iterations, but the above list is the most important one (for me personally)

support command substitution `$(cmd)` (and maybe `(cmd)`?)

Support command substitution.

I'm not sure we should support backtick-style command substitutions, because it's too error prone as a user.

The $(command) substitution should create a new AST node.
command substitution can happen as a parameter, inside of a string literal (?) and the command's program name to be executed could be a command substitution itself, too.

examples

$(echo -n ls) -h -l -a
echo $(ps -ef)
echo "Hello, $(whoami)"

support tilde expansion `~`

when parsing a statement or parameter, a leading ~ should be expanded to the current user's home directory

~/path/to/command
command ~/path/to/file
cd ~

History file (command completion)

For the history other shells are using different ways to store history,
for example for fish this is $HOME/.local/share/fish/fish_history file with entries like

- cmd: clear
  when: 1702971673

for zsh file $HOME/.zsh_history with entries

: 1690200654:0;git clean -fdx

for bash file $HOME/.bash_history with entries

ll (just a command)

I think that in endo we should not create any files directly in $HOME directory but use something similar to fish. Also what I think might be good is to be able to merge history files between different machines either automatically or with some provided script, for example some of the tools for shell history like atuin provide synchronization via server

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.