Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get command line arguments in Ceylon?

Tags:

ceylon

In a command line Java application you can get arguments through the args parameter:

public static void main(String[] args) {

How can I do something similar in Ceylon? I tried copying the Java style:

shared void run(String[] args) {

but got an error since that is not allowed:

ceylon run: Cannot run toplevel method 'test.project.run': 
it should have no parameters or they should all have default values.

I've been reading the ceylon-lang.org tour but I haven't found the answer.

like image 339
KPD Avatar asked Feb 24 '26 23:02

KPD


1 Answers

Use the top-level process object in the language module.

String[] arguments = process.arguments;
String? argument = process.namedArgumentValue("name");
if (process.namedArgumentPresent("name")) {
    // ...
}
like image 144
gdejohn Avatar answered Feb 27 '26 01:02

gdejohn