Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ All notable changes to this project will be documented in this file.

## [0.2]
### Added
- Syntax highlight.
- JShell-like Kotlin snippets.
- Completely new REPL architecture with object based class layout `kshell-repl-api`.
- HDFS browser plugin.
- Kotlin interpreter for Zeppelin.

### Changed
- Switch to JLine3
- Kotlin version 1.2.20 -> 1.2.30.
- Unit testes moved to `kshell-repl-api`.

### Fixed
- Custom REPL fixes [#7](http://github.com/khud/sparklin/issues/7)
- Custom REPL fixes [#7](http://github.com/khud/sparklin/issues/7).
- Problem with custom commands which start with the same letter.

### Removed
Expand All @@ -30,8 +32,8 @@ All notable changes to this project will be documented in this file.
- Added 2 methods to `ConsoleReader` to support history changes.

### Fixed
- Problem with multiline code [#9](http://github.com/khud/sparklin/issues/9)
- Doubled colon problem [#10](http://github.com/khud/sparklin/issues/10)
- Problem with multiline code [#9](http://github.com/khud/sparklin/issues/9).
- Doubled colon problem [#10](http://github.com/khud/sparklin/issues/10).

## [0.1.1] - 2018-02-08
### Added
Expand Down
4 changes: 2 additions & 2 deletions bin/kshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ KOTLIN_REFLECT=${MAVEN_REPO_BASE}/kotlin-reflect/${KOTLIN_VERSION}/kotlin-reflec

# JLine2 console support
FUSE_JANSI=$HOME/.m2/repository/org/fusesource/jansi/jansi/1.15/jansi-1.15.jar
KSHELL_CONSOLE_JLINE2=$HOME/.m2/repository/sparklin/kshell-console-jline2/${SPARKLIN_VERSION}/kshell-console-jline2-${SPARKLIN_VERSION}.jar
KSHELL_CONSOLE_JLINE3=$HOME/.m2/repository/sparklin/jline3-shaded/${SPARKLIN_VERSION}/jline3-shaded-${SPARKLIN_VERSION}.jar
KSHELL_REPL_API=$HOME/.m2/repository/sparklin/kshell-repl-api/${SPARKLIN_VERSION}/kshell-repl-api-${SPARKLIN_VERSION}.jar

# KShell path
KSHELL=$HOME/.m2/repository/sparklin/kshell/${SPARKLIN_VERSION}/kshell-${SPARKLIN_VERSION}.jar

JARS=${KOTLIN_COMPILER}:${KOTLIN_STDLIB}:${KOTLIN_REFLECT}:${KOTLIN_SCRIPT_RUNTIME}:${KSHELL_CONSOLE_JLINE2}:${KSHELL_REPL_API}
JARS=${KOTLIN_COMPILER}:${KOTLIN_STDLIB}:${KOTLIN_REFLECT}:${KOTLIN_SCRIPT_RUNTIME}:${KSHELL_CONSOLE_JLINE3}:${KSHELL_REPL_API}

java -classpath ${JARS}:${KSHELL} sparklin.kshell.KotlinShell $@
4 changes: 2 additions & 2 deletions bin/sparklin-spark1x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ KOTLIN_REFLECT=${MAVEN_REPO_BASE}/kotlin-reflect/${KOTLIN_VERSION}/kotlin-reflec

# JLine2 console support
FUSE_JANSI=$HOME/.m2/repository/org/fusesource/jansi/jansi/1.15/jansi-1.15.jar
KSHELL_CONSOLE_JLINE2=$HOME/.m2/repository/sparklin/kshell-console-jline2/${SPARKLIN_VERSION}/kshell-console-jline2-${SPARKLIN_VERSION}.jar
KSHELL_CONSOLE_JLINE3=$HOME/.m2/repository/sparklin/jline3-shaded/${SPARKLIN_VERSION}/jline3-shaded-${SPARKLIN_VERSION}.jar
KSHELL_REPL_API=$HOME/.m2/repository/sparklin/kshell-repl-api/${SPARKLIN_VERSION}/kshell-repl-api-${SPARKLIN_VERSION}.jar

# Spark 1.x support
Expand All @@ -30,7 +30,7 @@ KSHELL=$HOME/.m2/repository/sparklin/kshell/${SPARKLIN_VERSION}/kshell-${SPARKLI
# Apache Spark home directory must point to Spark version 1.x > 1.6
SPARK_HOME=$HOME/Programs/spark-1.6.1-bin-hadoop2.6

JARS=${KOTLIN_COMPILER},${KOTLIN_STDLIB},${KOTLIN_REFLECT},${KOTLIN_SCRIPT_RUNTIME},${KSHELL_CONSOLE_JLINE2},${KSHELL_REPL_API},${SPARKLIN_PLUGIN},${HDFS_BROWSER_PLUGIN}
JARS=${KOTLIN_COMPILER},${KOTLIN_STDLIB},${KOTLIN_REFLECT},${KOTLIN_SCRIPT_RUNTIME},${KSHELL_CONSOLE_JLINE3},${KSHELL_REPL_API},${SPARKLIN_PLUGIN},${HDFS_BROWSER_PLUGIN}

${SPARK_HOME}/bin/spark-submit --jars=${JARS} --conf "spark.driver.extraJavaOptions=-Dconfig.path=${SPARKLIN_CONFIG}" \
--master "local[2]" --class "sparklin.kshell.KotlinShell" \
Expand Down
4 changes: 2 additions & 2 deletions bin/sparklin-spark2x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ KOTLIN_REFLECT=${MAVEN_REPO_BASE}/kotlin-reflect/${KOTLIN_VERSION}/kotlin-reflec

# JLine2 console support
FUSE_JANSI=$HOME/.m2/repository/org/fusesource/jansi/jansi/1.15/jansi-1.15.jar
KSHELL_CONSOLE_JLINE2=$HOME/.m2/repository/sparklin/kshell-console-jline2/${SPARKLIN_VERSION}/kshell-console-jline2-${SPARKLIN_VERSION}.jar
KSHELL_CONSOLE_JLINE3=$HOME/.m2/repository/sparklin/jline3-shaded/${SPARKLIN_VERSION}/jline3-shaded-${SPARKLIN_VERSION}.jar
KSHELL_REPL_API=$HOME/.m2/repository/sparklin/kshell-repl-api/${SPARKLIN_VERSION}/kshell-repl-api-${SPARKLIN_VERSION}.jar

# Spark 2.x support
Expand All @@ -30,7 +30,7 @@ KSHELL=$HOME/.m2/repository/sparklin/kshell/${SPARKLIN_VERSION}/kshell-${SPARKLI
# Apache Spark home directory must point to Spark version 2.x
SPARK_HOME=$HOME/Programs/spark-2.2.0-bin-hadoop2.7

JARS=${KOTLIN_COMPILER},${KOTLIN_STDLIB},${KOTLIN_REFLECT},${KOTLIN_SCRIPT_RUNTIME},${KSHELL_CONSOLE_JLINE2},${KSHELL_REPL_API},${SPARKLIN_PLUGIN},${HDFS_BROWSER_PLUGIN}
JARS=${KOTLIN_COMPILER},${KOTLIN_STDLIB},${KOTLIN_REFLECT},${KOTLIN_SCRIPT_RUNTIME},${KSHELL_CONSOLE_JLINE3},${KSHELL_REPL_API},${SPARKLIN_PLUGIN},${HDFS_BROWSER_PLUGIN}

${SPARK_HOME}/bin/spark-submit --jars=${JARS} --conf "spark.driver.extraJavaOptions=-Dconfig.path=${SPARKLIN_CONFIG}" \
--master "local[2]" --class "sparklin.kshell.KotlinShell" \
Expand Down
4 changes: 3 additions & 1 deletion conf/spark1x.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ plugins=sparklin.kshell.plugins.LoadFilePlugin, \
sparklin.kshell.plugins.HelpPlugin, \
sparklin.kshell.plugins.PastePlugin, \
sparklin.spark1x.Spark1xPlugin, \
sparklin.hdfsbrowser.HdfsBrowserPlugin
sparklin.hdfsbrowser.HdfsBrowserPlugin, \
sparklin.kshell.plugins.SyntaxPlugin, \
sparklin.kshell.plugins.PromptPlugin
4 changes: 3 additions & 1 deletion conf/spark2x.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ plugins=sparklin.kshell.plugins.LoadFilePlugin, \
sparklin.kshell.plugins.HelpPlugin, \
sparklin.kshell.plugins.PastePlugin, \
sparklin.spark2x.Spark2xPlugin, \
sparklin.hdfsbrowser.HdfsBrowserPlugin
sparklin.hdfsbrowser.HdfsBrowserPlugin, \
sparklin.kshell.plugins.SyntaxPlugin, \
sparklin.kshell.plugins.PromptPlugin
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package sparklin.hdfsbrowser

import sparklin.kshell.console.ConsoleReader
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.fs.Path
import sparklin.kshell.BaseCommand
import sparklin.kshell.KShell
import sparklin.kshell.Plugin
import sparklin.kshell.calcHumanReadableSize
import sparklin.kshell.configuration.Configuration
import sparklin.kshell.plugins.SparkPlugin
import kotlin.reflect.KClass
Expand All @@ -15,7 +15,6 @@ import org.apache.hadoop.conf.Configuration as HadoopConfiguration
class HdfsBrowserPlugin : Plugin {
private lateinit var repl: KShell
private lateinit var fs: FileSystem
private lateinit var console: ConsoleReader
private var workingDirectory = "."

inner class LsCommand(conf: Configuration) : BaseCommand() {
Expand All @@ -29,7 +28,7 @@ class HdfsBrowserPlugin : Plugin {
val p = line.indexOf(' ')
val parseResult = parseOpts(if (p < 0) "" else line.substring(p + 1).trim(), "h")
when (parseResult) {
is ParseResult.ParseError -> console.println(parseResult.msg)
is ParseResult.ParseError -> println(parseResult.msg)
is ParseResult.ParsedOptions -> {
val path = if (parseResult.other.isBlank()) workingDirectory else parseResult.other
listFiles(path, parseResult.opts.isNotEmpty())
Expand All @@ -41,7 +40,6 @@ class HdfsBrowserPlugin : Plugin {
override fun init(repl: KShell, config: Configuration) {
this.repl = repl
this.fs = FileSystem.get(findHadoopConfiguration(config))
this.console = config.getConsoleReader()

repl.registerCommand(LsCommand(config))
}
Expand All @@ -66,18 +64,10 @@ class HdfsBrowserPlugin : Plugin {
fs.listStatus(Path(path)).forEach {
val summary = fs.getContentSummary(it.path)
val size = if (isHumanReadable) calcHumanReadableSize(summary.length) else summary.length.toString()
console.println(String.format("%-20s%s", size, it.path))
println(String.format("%-20s%s", size, it.path))
}
}

private fun calcHumanReadableSize(bytes: Long, si: Boolean = false): String {
val unit = if (si) 1000 else 1024
if (bytes < unit) return "$bytes B"
val exp = (Math.log(bytes.toDouble()) / Math.log(unit.toDouble())).toInt()
val pre = (if (si) "kMGTPE" else "KMGTPE")[exp - 1] + if (si) "" else "i"
return String.format("%.1f %sB", bytes / Math.pow(unit.toDouble(), exp.toDouble()), pre)
}

override fun cleanUp() { }

companion object {
Expand Down
49 changes: 49 additions & 0 deletions jline3-shaded/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sparklin</groupId>
<artifactId>sparklin</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>


<artifactId>jline3-shaded</artifactId>
<version>0.2-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>3.6.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.jline</pattern>
<shadedPattern>sparklin.kshell.org.jline</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
131 changes: 0 additions & 131 deletions kshell-console-jline2/pom.xml

This file was deleted.

Loading