Skip to content

Commit

Permalink
Merge pull request cheat#42 from grumpyf0x48/master
Browse files Browse the repository at this point in the history
Add cheatsheet for jbang
  • Loading branch information
chrisallenlane authored Oct 6, 2020
2 parents 33c252b + dac536b commit 5dc706b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions jbang
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Create a new command line application using Picocli
jbang init --template=cli CmdLineApp.java

# Edit application with Visual Studio Code
jbang edit --open=code CmdLineApp.java

# Edit application with IDEA and have the project regenerated on dependencies changes
jbang edit --live --open=idea CmdLineApp.java

# Rebuild application in cache without starting it
jbang build CmdLineApp.java

# Run command line application with jbang
jbang CmdLineApp.java command arg1 arg2...

# Run command line as a script
./CmdLineApp.java command arg1 arg2...

# Run a Java code snippet (Java 9 and later)
echo 'Files.list(Paths.get("/etc")).forEach(System.out::println);' | jbang -

# Debug
jbang --debug CmdLineApp.java command arg1
# Then start debugger in IDEA once port is printed

# Run a script from the network
jbang https://github.com/jbangdev/jbang-catalog/blob/master/hello.java

# Run a jbang script referenced in a catalog
# Where hello.java is located in jbang-catalog repository of GitHub jbangdev user
jbang hello@jbangdev

# Run a jar file from its GAV
jbang io.swagger:swagger-codegen-cli:RELEASE --help

# Install JDK 14 to be used with jbang
jbang jdk install 14

# Force usage of JDK 14 in a jbang script
## Add //JAVA 14 to the first lines of the script
## Then start it using jbang

# List jbang installed JDK
jbang jdk list

# Clear jbang cache
jbang cache clear

# Install auto-completion script for Bash
jbang completion | sudo tee /etc/bash_completion.d/jbang

0 comments on commit 5dc706b

Please sign in to comment.