A simple tools to get the entries of a java projects, based on javalang library.
You can simply install it with pip
command line from the official PyPI site.
pip install jentry
For more information about installation, you can refer to the installation guide.
You can directly use jentry
CLI to get the entry of a java project. Such as the command below
jentry demo
The output should be like as shown follow (in this project, we have 2 different entries)
Main
homework.Main
You can get exactly one entry with -F
command
jentry -F demo
The output should be
Main
This command can be used when you are trying to run a compiled java project, like this
java -cp target:${CLASSPATH} $(jentry -F demo)
The entry it found will be applied into the java
command line.
Actually, these entries can be printed with prettier ways, such as json and table.
jentry -f json demo
The json-formatted output.
[
{
"entrance": "Main",
"package": null,
"class": "Main",
"file": "demo/2018_spring_16061104_10/src/Main.java"
},
{
"entrance": "homework.Main",
"package": "homework",
"class": "Main",
"file": "demo/oo_course_2019_17373331_homework_2/src/homework/Main.java"
}
]
And if the -f
option is assigned to table
jentry -f table demo
A table with all the entries will be placed together.
+---------------+----------+-------+----------------------------------------------------------------+
| Entry | Package | Class | Filename |
+---------------+----------+-------+----------------------------------------------------------------+
| Main | <none> | Main | demo/2018_spring_16061104_10/src/Main.java |
| homework.Main | homework | Main | demo/oo_course_2019_17373331_homework_2/src/homework/Main.java |
+---------------+----------+-------+----------------------------------------------------------------+
Other features can be found in the help information, which can be displayed with -h
option.
jentry -h
Usage: jentry [OPTIONS] [SOURCES]...
Jentry - find the entry of your java project.
Options:
-v, --version Show package's version information.
-f, --format [table|json|entry]
The format to display the entries [default:
entry]
-s, --sorted_by [file|package|class|entry]
The order to sorted by. [default: file]
-r, --reverse Reverse the sorted result, only applied when
-s is used. [default: False]
-F, --first_only Only show the first entry. [default: False]
-h, --help Show this message and exit.
jentry
can be imported into python
from jentry.entry.script import load_entries_from_project
if __name__ == '__main__':
for entry in load_entries_from_project('demo'):
print(repr(entry))
The output should be
<JavaEntry class: Main, filename: 'demo/2018_spring_16061104_10/src/Main.java'>
<JavaEntry class: homework.Main, filename: 'demo/oo_course_2019_17373331_homework_2/src/homework/Main.java'>
jentry
released under the Apache 2.0 license.