BradleyChatha / jcli

A CLI framework for D
MIT License
23 stars 4 forks source link

Add exist codes to ResultOf #47

Closed merlindiavova closed 2 years ago

merlindiavova commented 2 years ago

Hi @BradleyChatha

Firstly thanks for the time and effort taken to build this really cool CLI framework! I'm just starting our in D and I love building CLI's and your project has been super helpful.

My suggestion/request is to add exit codes to the ResultOf struct.

enum Status {
    ok = 0,
    failure = 1,

    // Temporary failure, indicating something that is not really an error.
     // In sendmail, this means that a mailer (e.g.) could not create a
     // connection, and the request should be reattempted later.
    tempFail = 75,
}

string requestData = somethingThatMakesARequest();
ResultOf!string.error("Network is unavailable. Your request will be retried shortly.", Status.tempFail);

As you can see above being able to add exit codes provides extra contents and better handling of the programs exist status by end users and possible piped programs.

I hope this makes sense and will be considered.

Merlin

BradleyChatha commented 2 years ago

Hi Merlin,

Great to hear this library is of some use to you!

This suggestion makes sense, I'll get to work on something likely next week.

On the off side, if you're into making CLI apps, there's this great library called scriptlike which you might like.

merlindiavova commented 2 years ago

Thanks Bradley!

scriptlike is super awesome! thanks for link!

I have some other suggestions/recommendations on to help for jcli. Would you prefer separate issues for each?

BradleyChatha commented 2 years ago

Yeah, separate issues would be fine.