Code Monkey home page Code Monkey logo

hosh's People

Contributors

dependabot[bot] avatar dfa1 avatar

Stargazers

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

Watchers

 avatar  avatar

hosh's Issues

API for describe a command

Problem:
Thread name should be improved, version (v0.0.27) reports:

[command='Sink'] instead [command='sink']
[command='ListFiles /'] instead of [command='ls /']
[command='ExternalCommand pom.xml'] instead of [command='cat pom.xml']
[command='DefaultCommandWrapper 1'] instead of [command='benchmark 1']

Solution:
provide a simple API to describe commands, something like Junit Description. As bonus would be nice to provide line number and original arguments (before expansion).

improve versioning

File git.properties contains several other useful properties, such as:

  • git.commit.id.describe=v0.0.23-19-ge13c22b-dirty
  • git.commit.time=2019-02-13T21\:43\:30+0100

These properties would be very useful in bug reports and for general usage.

license for every file

     <!-- Resolve the current year. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${version.plugin.buildhelp}</version>
                <executions>
                    <execution>
                        <id>timestamp-property</id>
                        <goals>
                            <goal>timestamp-property</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <locale>en_US</locale>
                            <name>current.year</name>
                            <pattern>yyyy</pattern>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Add license headers to all files. -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>3.0</version>
                <inherited>false</inherited>
                <configuration>
                    <header>${project.basedir}/NOTICE</header>
                    <aggregate>true</aggregate>
                    <failIfMissing>true</failIfMissing>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <properties>
                        <current.year>${current.year}</current.year>
                    </properties>
                    <includes>
                        <include>**/main/java/**/*.java</include>
                    </includes>
                    <strictCheck>true</strictCheck>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

new Values type

Hosh has different value types buried in the modules:

  • None
  • Duration (withTime)
  • Numbers
  • Instant
  • Regex/Pattern
  • Error, often we capture an exception and create a simple Text

windows: make use of PATHEXT

Right now Hosh on Windows tries just ".exe". This could be improved by using PATHEXT:

PathExt environment variable returns a list of the file extensions that the operating system considers to
be executable. When executing a command line that does not contain an extension, the command
interpreter (cmd.exe) uses the value of this environment variable to determine which extensions to look
for and in what order.[1]
http://environmentvariables.org/PathExt

cannot capture `CommandWrapper` output in certain cases

Looks like in certain cases it is not possible to capture the output produced by the after method in CommandWrapper

This is working as expected:

hosh:1> benchmark 1 { ls } | schema
path size

Instead this is not working (no output):

hosh:2> benchmark 1 { ls | sink } | schema

whereas this is working as expected:

hosh:4> benchmark 1 { sink } | schema
count best worst average

specialize Record implementations?

Try to optimize cpu/memory usage by creating specialized versions of Record with 0, 1, more keys. By now, most of Record instances contain only 1 key.

Since Record don't allows removal and it uses a fluent interface should be simple to change implementation:

Empty -> SIngleton -> Generic

ctrl-C outside a pipeline terminate the process

Problem:
hitting ctrl-C when a single, not pipeline, external or a native command is running, terminates the whole shell

Solution:
let the Interpreter handle the execution + handling of ctrl-C. Probably a ExecutorAware interface is needed to let the pipeline to submit jobs

Benefit:
have a single point where futures are created, thread name assigned.

simplify supervisor

move all exception handling in the Supervisor, keeping the Interpreter simpler

custom AssertJ

Problem:
unit tests have these asserts:

assertThat(exitStatus.value()).isEqualTo(21);
assertThat(exitStatus.value()).isEqualTo(0);
assertThat(exitStatus.isSuccess()).isTrue();

Solution:
custom assert for ExitStatus to be more readable

weird behaviour of 'less'

less is not working properly when used in a pipeline:

less pom.xml works fine (i.e. pagination)
cat pom.xml | less does not work (i.e. no pagination)

Tested on macOS Mojave:

less 487 (POSIX regular expressions)
Copyright (C) 1984-2016  Mark Nudelman

sort command problems

This is how sort should be used:

hosh:1> help | sort command
bell
cat
cd
clear
count
...

Bugs:

  1. this uses external command 'sort', causing the shell to stuck
hosh:2> help | sort 
  1. when key is not found nothing is signaled to the user
hosh:1> help | sort asdasdasdasdasdasd
... normal output

pitest

Latest version is: 1.4.5

           <plugin>
                <groupId>org.pitest</groupId>
                <artifactId>pitest-maven</artifactId>
                <version>${version.plugin.pitest}</version>
                <configuration>
                    <targetClasses>
                        <param>${pitest.target}.*</param>
                    </targetClasses>
                    <targetTests>
                        <param>${pitest.target}.*</param>
                    </targetTests>
                </configuration>
            </plugin>

improve error handling for access denied exceptions

Problem:

hosh:69> ls
/tmp/KSDownloadAction.mMjQifWXyB

there is no clue that this is an error. Only with debug it is possible to see it:

2019-03-23T09:26:43.142 [WARNING] [command='ListFiles'] - caught I/O error
java.nio.file.AccessDeniedException: /tmp/KSDownloadAction.mMjQifWXyB
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)

improve file system completer

Problem:
/usr/ TAB yields /usr without proposing further matches
additionally at start of line should pick only executables

Solution:
TDB

Benefit:
to have a useful filesystem autocomplete

sending output to native commands

problem:
lines | wc -l does not work!

solution:
read from Channel in and write to the native process OutputStream

benefit:
interoperability between native and non-native commands

file watcher

dogfooding : watch for changes in a directory sending events downstream.
Events could be records with two keys: type (added, removed, modified) and path, downstream consumer could start a job (e.g. mvn clean verify).

weird variable expansion

hosh:1> set FOO 1
hosh:2> set BAR 2
hosh:3> echo ${FOO}${BAR}
1 2
hosh:4> echo "${FOO}${BAR}"
unknown variable: FOO}${BAR

smart completion with commands

Ideally command completion should be programmable. But let's try to provide some obvious
defaults:

  • cd should propose only directories
  • kill should propose only local process ids, along with a brief description

performance on Windows 7 is 100x slower than Macosx

Problem:

Windows 7 (running OpenJDK 11.0.2)

hosh:1> benchmark 100 { rand | take 10000 | count }
100 1,144 1,246 1,159

Same Hosh version on Macosx (OpenJDK 11.0.2)

hosh:1> benchmark 100 { rand | take 10000 | count }
100 8 97 13

record builder

Problem:
have a more efficient way to create records with more than 2 keys (instead of discarding 2 or 3 hashmaps)

Solution:
have a builder patter for Record, something like:

new Record.Builder().entry(k1, v1).entry(k2, v2)....build()

cannot use capture wrapper output

Problem:
it would be useful to capture output coming from wrappers, especially benchmark:

hosh:5> benchmark 10  { ls | drop 1000 } | table
10 1 3 2

Solution: ???

Pipeline cannot resolve variables

problem:
cannot resolve variables in certain cases:

echo ${OS_ENV_VARIABLE} | take 1
withTime { echo ${OS_ENV_VARIABLE} } 

solution:
using another (!) marker interface to inject an ArgumentResolver

failure injection

Problem:
since it is hard to test all possible errors it would be nice to have a way to inject failures
without writing java code

Solution:
create a command to raise exceptions according to some rules:

  • interrupted
  • null pointers

Benefit:
it would be easy to test error scenarios for pipelines and wrappers

improve tests for SIGINT handling

SIGINT handling is quite easy to break and very boring to be manually tested.
This is just a note about some scenarios to test:

  • single external command like cat
  • single built-in command like rand
  • pipeline with built-in and external commands
  • pipeline with wrappers
  • benchmark

drop SLF4J

replace with JUL for several reason:

performance command

problem:
measure progress in performance and optmization

solution:
write a command that repeat a given block for several times and report the best/worst/average

benefit:
explore possible optimization faster (e.g. #30 and #3)

model pipelines as Command

Compiler should create and assemble pipelines as Command to keep the interpreter ignorant as much as possible.

Same technique could be used for compiling a CommandWrapper.

automatic DI

Problem:
Commands need to access system services and user data. Code should be cluttered by manual DI injection e.g.PipelineCommand' must be StateAwarejust to forward State to children. Additionally builtin commands are singleton (i.e. sole instance registered) and yet they have a mutablesetState()orsetTerminal()`.

Solution:
https://github.com/andrus/di-comparison

DI, but spring is a big dependency (spring-core 1.2MB + spring-beans 600KB). Dagger 2 could be a good trade off:
https://github.com/google/dagger

Benefit:
Remove some boilerplate code and tests.

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.