Code Monkey home page Code Monkey logo

kotlin-shell-examples's Introduction

Kotlin Shell Examples

This repository provides examples on using Kotlin Shell library

The examples can be run both via command line and Intellij IDEA.

All examples from kotlin can be executes as scripts and all examples from kts can be executed as part of Kotlin code.

As scripting support in Intellij IDEA is still under development, examples may not run properly on every versions. Despite the highlighting and completion should work fine.

run it with command line

kotlin

type:

./gradlew -Psample=[RELATIVE-CLASS-PATH] -Plogs=true execute [--args="ARGS"]

example:

$ cd kotlin
$ ./gradlew -Psample=basic.HelloKt execute
hello world!

To see logs add -Plogs=true parameter.

kts

To run scripts you need kshell installed

type:

cd kts
kshell src/kotlin/[PATH-TO-SAMPLE] [ARGS]

example:

$ cd kts
$ kshell src/kotlin/basic/hello.sh.kts
hello world!

run it with Intellij IDEA

kotlin

After importing Gradle project you will be able to run main() functions in sample classes.

kts

After importing Gradle project you will be able to run script files.

file template

File kts/fileTemplate_sh_kts contains template definition for Intellij. To use it put this file in ~/Library/Preferences/IntelliJIdea/fileTemplates with name KotlinShell.sh.kts.

logging

Kotlin Shell features slf4j logging interface. All examples use NOP logger by default. Configurations for loggers can be found under resources/log4j2.xml.

kotlin

By default Gradle project imports NOP logger. To change it use these instructions.

kts

Both kshell and Gradle uses NOP logger by default. You can change this dependency manually to see the logs.

side by side examples

In sidebyside package there are located side by side examples of scripts written with Kotlin Shell and Bash. They are always equal in terms of evaluation.

kotlin-shell-examples's People

Contributors

alexbeggs avatar jakubriegel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

alexbeggs

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.