mcli icon indicating copy to clipboard operation
mcli copied to clipboard

Why require Sys.exit(0)?

Open jasononeil opened this issue 11 years ago • 3 comments

It seems that if I don't do a Sys.exit(0) in my action then it re-runs the dispatch, and will often then complain about a "arguments not supplied" error etc. Is this a deliberate design decision or an oversight?

The case I want to support is:

public function doThingA() { Sys.exit(0); }
public function doThingB() { Sys.exit(0); }
public function doTwoThings() { doThingA(); doThingB(); Sys.exit(0); }

I can work around it easily enough using private functions that do the actual work, but if it's just an oversight and not a deliberate decision I'll fix it instead :)

jasononeil avatar Jul 15 '14 05:07 jasononeil

Hello! Sorry for taking so long to answer I cannot reproduce the need of Sys.exit. Can you elaborate on when it's needed? Thanks!

waneck avatar Dec 01 '14 23:12 waneck

I finally came across it again and figured it out.

It was a misunderstanding on my part, I had this:

public function runDefault()
{
    Sys.println(this.showUsage());
}

I thought runDefault happened only when no other task is called, but it seems it runs every time, unless "preventDefault()" is called, (or, am I right, if one of the parameters of runDefault is not optional?)

Either way this behaviour is different to haxe.web.Dispatch(). I can live with the behaviour, but it would be nice to document it in the README.

jasononeil avatar Jan 30 '15 12:01 jasononeil

I guess that it's indeed strange that runDefault will always execute except when it has arguments. I'll look into it.

waneck avatar Jan 30 '15 13:01 waneck