NPM Commander merge 2 .command together

Hey magical people!

Is there a way for me to merge 3 separete commander .command into 1 segment?

the way i have it now is:


friday
    .command('init')
    .description('Initialize friday')
    .action(() => {
        console.log(
            chalk.yellow(
                figlet.textSync('Friday', { horizontalLayout: 'full' })
            )
        );
    });

friday
    .command('github')
    .description('ask for github credentials')
    .action(async () => {
        let token = github.getStoredGithubToken();
        if (!token) {
            await github.setGithubCredentials();
            token = await github.registerNewToken();
        }
        console.log(token);
    });

friday
    .command('test')
    .description('Create a new repository on github')
    .action(async () => {
        const getGithubToken = async () => {
            // Fetch token from config store
            let token = github.getStoredGithubToken();
            if (token) {
                return token;
            }

            // No token found, use credentials to access Github account
            await setGithubCredentials();

            // register new token
            token = await github.registerNewToken();
            return token;
        }

        try {
            // Retrieve & set Auth token
            const token = await getGithubToken();
            github.githubAuth(token);

            // Create remote repo
            const url = await repo.createRemoteRepo();

            // create gitignore file
            await repo.createGitIgnore();

            // set up local repo and push to remote
            const done = await repo.setupRepo(url);

            if (done) {
                console.log(chalk.green('All done'));
            }
        } catch (error) {
            if (error) {
                switch (error.status) {
                    case 401:
                        console.log(chalk.red('Could\'t log you in. Please provide correct credentials or token.'));
                        break;
                    case 422:
                        console.log(chalk.red('There already exists a remote repository with the same name.'));
                        break;
                    default:
                        console.log(error);
                        break;
                }
            }
        }
    });

friday.parse(process.argv);

if (!friday.args.length) {
    friday.help();
}

In the CLI it returns:


$ node friday.js
Usage: friday [options] [command]

Options:
  -h, --help  output usage information

Commands:
  init        Initialize friday
  github      ask for github credentials
  test        Create a new repository on github

Now how do i make it “merge” and as soon as i run node friday.js it not only initiates friday but it also ask for the github credentials ?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Thank you @ArielLeslie

Also for further update:

I found some reference material, but i don’t know how to make it work:

// file: ./examples/pm
var program = require('commander');
 
program
  .version('0.1.0')
  .command('install [name]', 'install one or more packages')
  .command('search [query]', 'search with optional query')
  .command('list', 'list packages installed', {isDefault: true})
  .parse(process.argv);

is there anyone that can help clarify this section ?