<commit_before>#!/usr/bin/env node

let program = require('commander')
let inquirer = require('inquirer')
let prompt = inquirer.createPromptModule()
let colors = require('../lib/colors-custom')
let configurationManager = require('../lib/ConfigurationManager.js')
let SSHConnection = require('../lib/SSHConnection')
let ConnectionConfiguration = require('../lib/ConnectionConfiguration')

async function getConnectionConfigurationProperty (message, name, defaultValue = null) {
    let inputNameInquirer = {
        type: 'input',
        message: message,
        name: name,
        default: defaultValue
    }

    let property = await prompt(inputNameInquirer)

    return property[name]
}

async function selectConnectionConfiguration () {
    let allConnectionConfigurationChoices = configurationManager.getConnectionConfigurationList()

    if (allConnectionConfigurationChoices.length === 0) {
        console.log(colors.error(new Error('no connection configuration found into "' + configurationManager.getConnectionConfigurationFilePath() + '". Please use "add" command.')))
        exit(1)
    }

    let selectConnectionConfigurationInquirer = {
        type: 'list',
        message: 'Select an connection',
        name: 'uuid',
        choices: allConnectionConfigurationChoices
    }

    let result = await prompt(selectConnectionConfigurationInquirer)
    let selectedConnectionConfiguration = null

    try {
        selectedConnectionConfiguration = configurationManager.getConnectionConfiguration(result.uuid)
    } catch (e) {
        exit(1)
    }

    return selectedConnectionConfiguration
}

function exit (code) {
    process.exit(code)
}

program
    .version('1.0.0')
    .description('A SSH manager to store a list of SSH connection configuration')

program
    .command('show')
    .description('show all projects SSH configurations')
    .action(() => {
        configurationManager.showConnectionConfigurations()
    })

program
    .command('delete')
    .description('delete an SSH connection configuration')
    .action(async () => {
        let projectConfiguration = await selectConnectionConfiguration()
        configurationManager.deleteConnectionConfiguration(projectConfiguration.uuid)
    })

program
    .command('add')
    .description('add a new SSH connection configuration')
    .action(async () => {
        let name = await getConnectionConfigurationProperty('Connection name', 'name')
        let description = await getConnectionConfigurationProperty('Description', 'description')
        let user = await getConnectionConfigurationProperty('User', 'user')
        let server = await getConnectionConfigurationProperty('Server', 'server')
        let port = await getConnectionConfigurationProperty('Port', 'port', 22)

        configurationManager.addConnectionConfiguration(name, description, user, server, port)
    })

program
    .command('connect')
    .description('start an SSH connection')
    .action(async () => {
        let projectConfiguration = await selectConnectionConfiguration()
        let cc = new ConnectionConfiguration(projectConfiguration)
        SSHConnection.init(cc)
        SSHConnection.start(exit)
    })

program.parse(process.argv)
<commit_msg>"connect" command is now default command<commit_after>#!/usr/bin/env node

let program = require('commander')
let inquirer = require('inquirer')
let prompt = inquirer.createPromptModule()
let colors = require('../lib/colors-custom')
let configurationManager = require('../lib/ConfigurationManager.js')
let SSHConnection = require('../lib/SSHConnection')
let ConnectionConfiguration = require('../lib/ConnectionConfiguration')

async function getConnectionConfigurationProperty (message, name, defaultValue = null) {
    let inputNameInquirer = {
        type: 'input',
        message: message,
        name: name,
        default: defaultValue
    }

    let property = await prompt(inputNameInquirer)

    return property[name]
}

async function selectConnectionConfiguration () {
    let allConnectionConfigurationChoices = configurationManager.getConnectionConfigurationList()

    if (allConnectionConfigurationChoices.length === 0) {
        console.log(colors.error(new Error('no connection configuration found into "' + configurationManager.getConnectionConfigurationFilePath() + '". Please use "add" command.')))
        exit(1)
    }

    let selectConnectionConfigurationInquirer = {
        type: 'list',
        message: 'Select an connection',
        name: 'uuid',
        choices: allConnectionConfigurationChoices
    }

    let result = await prompt(selectConnectionConfigurationInquirer)
    let selectedConnectionConfiguration = null

    try {
        selectedConnectionConfiguration = configurationManager.getConnectionConfiguration(result.uuid)
    } catch (e) {
        exit(1)
    }

    return selectedConnectionConfiguration
}

function exit (code) {
    process.exit(code)
}

async function connectAction () {
    let projectConfiguration = await selectConnectionConfiguration()
    let cc = new ConnectionConfiguration(projectConfiguration)
    SSHConnection.init(cc)
    SSHConnection.start(exit)
}

async function addAction () {
    let name = await getConnectionConfigurationProperty('Connection name', 'name')
    let description = await getConnectionConfigurationProperty('Description', 'description')
    let user = await getConnectionConfigurationProperty('User', 'user')
    let server = await getConnectionConfigurationProperty('Server', 'server')
    let port = await getConnectionConfigurationProperty('Port', 'port', 22)

    configurationManager.addConnectionConfiguration(name, description, user, server, port)
}

async function deleteAction () {
    let projectConfiguration = await selectConnectionConfiguration()
    configurationManager.deleteConnectionConfiguration(projectConfiguration.uuid)
}

program
    .version('1.0.0')
    .description('A SSH manager to store a list of SSH connection configuration')

program
    .command('show')
    .description('show all projects SSH configurations')
    .action(() => {
        configurationManager.showConnectionConfigurations()
    })

program
    .command('delete')
    .description('delete an SSH connection configuration')
    .action(deleteAction)

program
    .command('add')
    .description('add a new SSH connection configuration')
    .action(addAction)

program
    .command('connect')
    .description('start an SSH connection')
    .action(connectAction)

program.parse(process.argv)

// launch connect command if no argument given
if (program.args.length === 0) {
    connectAction()
}

{'fraction_non_alphanumeric': 0.10010569228446324, 'fraction_numerical': 0.0025668126226785445, 'mean_word_length': 4.083653108211819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3172457', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1571, 'n_words': 409}