Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: document exit codes in help text #69

Open
elliot-nelson opened this issue Jun 2, 2020 · 0 comments
Open

feature: document exit codes in help text #69

elliot-nelson opened this issue Jun 2, 2020 · 0 comments

Comments

@elliot-nelson
Copy link
Member

SUMMARY

I was recently working on an internal tool that needed some specific exit codes to play well with other tools, and I tried my hand at documenting the exit codes in the help screen itself. I took a screenshot:

exitcodeexample

Would it be useful if a user could add information about exit codes directly to their help screen with an API method?

Here's the code I used to add this info (I cheated and used the epilogue, and made calls into my style object for the styling):

    function formatHelpTextHash(header, hash) {
        const style = require('sywac-style-chunky');
        const keyLength = Math.max(...Object.keys(hash).map(key => String(key).length));

        return [
            style.group(header),
            ...Object.keys(hash).map(key => `  ${style.usageOptionsPlaceholder(key).padEnd(keyLength)}  ${hash[key]}`)
        ].join('\n');
    }

    sywac.epilogue(formatter.formatHelpTextHash({'Exit Codes:', {
            0: 'success',
            1: 'unexpected error',
            2: 'one or more nodes over the --consecutiveReboots limit',
            3: 'one or more nodes exactly at the --consecutiveReboots limit'
    });

DETAILS

Add an optional help text API method exitCodes to describe a list of exit codes and their meanings. Does not appear in help screen unless specified. Formatted using your styling... somehow. (I used .usageOptionsPlaceholder just because I liked the look in my case, but it could be more appropriate to create a specific style for this. Or we could pick something like .hints.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant