In C# langauge exists global system variable for this purpose.
Environment.CommandLine
This property provides access to the program name and any arguments specified on the command line when the current process was started.
Dart is asynchronous langauge. It allows self starting processes.
void main() {
task("foo", callback1);
task("baz", callback2);
}
Package tasks.
void task(String name, action()) {
schedule();
addTask(name. action);
}
void schedule() {
// Here we start timer if it not started.
// This timer will get cmd line arguments
// And executes task specified in cmd line arguments
}
P.S.
An official answer from Dart Team: "Not planned".
I cannot understand: "Why this is possible in other platforms through their libraries but in Dart platform this is not possible?".
Why only through "main" parameters which even not ensures that other isolates not substitute these arguments on the surrogate parameters that are not a real OS process command line arguments)?
Here examples:
Go language
func main() {
fmt.Println(len(os.Args), os.Args)
}
Rust language
fn main() {
let args = os::args();
println!("The first argument is {}", args[1]);
}
C# language
class Sample {
public static void Main() {
Console.WriteLine();
String[] arguments = Environment.GetCommandLineArgs();
Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", arguments));
}
}
Ruby language
ARGV.each do|a|
puts "Argument: #{a}"
end
Python language
import sys
print(sys.argv)
PHP language
foreach($argv as $value)
{
echo "$value\n";
}
Node.js language
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});
P.S.
Again, I am convinced that that Dart platform is not like everyone else.
This is only my opinion. It does not change anything.
Thanks, Günter Zöchbauer, for your concern, but do not need to edit this.