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

cli = require 'commander'

# Get version number from package.json to avoid redundancy
{ version } = require '../package'

module.exports = cli

######### - Argument checks and preprocess - ##########
cli.notEnoughArguments = process.argv.length <= 2

######### - CLI command, options and version definitions- ##########
cli.version version

# Subcommand-independent options
cli
    .option '-v, --verbose', "Show verbose output"

# Equal command
cli
    .command 'equal <original-program> [others...]'
    .alias 'e'
    .description 'Check equality of stdout output to verify correctness'
    .option '-a, --forward-args <[program-specification:]arguments-string>',
        "Forward arguments to the programs"
    .option '-l, --last',
        "Only check equality with the program with greatest lexicographic name"
    .action -> console.log "Equal"

# Compile command
cli
    .command 'compile <program> [others...]'
    .alias 'c'
    .description "Compile the given programs"
    .option '-f, --flags [program-specification:]<flags-string>',
        "Indicate flags to forward to the compilation of programs"
    .option '-a, --all', 'Compile all matching programs in lexicographic order'
    .action -> console.log "Compile"

# Speedup command
cli
    .command 'speedup <original-program> [others...]'
    .alias 's'
    .description "Compute speedups, execution times and t-student test"
    .option '-r, --repetitions <repetitions>',
        "Maximum program executions to average speedup for each of them."
    .option '-f, --force-steps',
        "Force to execute all steps independently of time limit"
    .option '-t, --time-limit <time_in_seconds>',
        "Time limit for all repetitions of a single program time check."
    .option '-c, --confidence-rate <rate>',
        "Confidence rate for the T-Student test"
    .option '-a, --forward-args [program-specification:]<arguments-string>',
        "Forward arguments to the programs"
    .option '-l, --last',
        "Only compute info for the program with greatest lexicographic name"
    .action -> console.log "Speedup"

# Profile command
cli
    .command 'profile <program> [others...]'
    .alias 'p'
    .description 'Profile the given programs'
    .option '-o, --o-profile [:options-string]',
        "Profile with OProfile's opannotate"
    .option '-g, --gprof [:options-string]', "Profile with gprof"
    .option '-n, --no-clean', "Do not clean profiler's intermediate files"
    .action -> console.log "Profile"

# TODO: Analyze = Speedup + Profile command
# TODO: All = Check + Speedup + Profile command

# Clean command
cli
    .command 'clean'
    .alias 'C'
    .description "Remove all executables in the directory"
    .action -> console.log "Clean"

cli.help() if cli.notEnoughArguments
cli.parse process.argv<commit_msg>Added command check and second aliases for commands<commit_after>#! /usr/bin/env coffee

cli = require 'commander'

# Get version number from package.json to avoid redundancy
{ version } = require '../package'

module.exports = cli

######### - Argument checks and preprocess - ##########
N_META_ARGUMENTS = 2

cli.notEnoughArguments = process.argv.length <= N_META_ARGUMENTS

# Replace the command argument if it is a second alias defined for convenience
# (Commander only allows one alias per command)
replaceSecondAlias = ->
    SECOND_ALIAS =
        spd: 'speedup'
        rm: 'clean'
        eq: 'equal'
        an: 'analyze'
        pf: 'profile'
        everything: 'all'

    realCommand = SECOND_ALIAS[process.argv[N_META_ARGUMENTS]]
    process.argv[N_META_ARGUMENTS] = realCommand if realCommand?

checkCommandExists = ->
    COMMANDS = ['speedup', 's', 'clean', 'C', 'equal', 'e', 'compile', 'c',
                'profile', 'p']

    # TODO: Replace for logger method call
    console.log "Invalid command" unless process.argv[N_META_ARGUMENTS] in COMMANDS

######### - CLI command, options and version definitions- ##########
cli.version version

# Subcommand-independent options
cli
    .option '-v, --verbose', "Show verbose output"

# Equal command
cli
    .command 'equal <original-program> [others...]'
    .alias 'e'
    .description 'Check equality of stdout output to verify correctness'
    .option '-a, --forward-args <[program-specification:]arguments-string>',
        "Forward arguments to the programs"
    .option '-l, --last',
        "Only check equality with the program with greatest lexicographic name"
    .action -> console.log "Equal" # TODO: Implement

# Compile command
cli
    .command 'compile <program> [others...]'
    .alias 'c'
    .description "Compile the given programs"
    .option '-f, --flags [program-specification:]<flags-string>',
        "Indicate flags to forward to the compilation of programs"
    .option '-a, --all', 'Compile all matching programs in lexicographic order'
    .action -> console.log "Compile" # TODO: Implement

# Speedup command
cli
    .command 'speedup <original-program> [others...]'
    .alias 's'
    .description "Compute speedups, execution times and t-student test"
    .option '-r, --repetitions <repetitions>',
        "Maximum program executions to average speedup for each of them."
    .option '-f, --force-steps',
        "Force to execute all steps independently of time limit"
    .option '-t, --time-limit <time_in_seconds>',
        "Time limit for all repetitions of a single program time check."
    .option '-c, --confidence-rate <rate>',
        "Confidence rate for the T-Student test"
    .option '-a, --forward-args [program-specification:]<arguments-string>',
        "Forward arguments to the programs"
    .option '-l, --last',
        "Only compute info for the program with greatest lexicographic name"
    .action -> console.log "Speedup" # TODO: Implement

# Profile command
cli
    .command 'profile <program> [others...]'
    .alias 'p'
    .description 'Profile the given programs'
    .option '-o, --o-profile [:options-string]',
        "Profile with OProfile's opannotate"
    .option '-g, --gprof [:options-string]', "Profile with gprof"
    .option '-n, --no-clean', "Do not clean profiler's intermediate files"
    .action -> console.log "Profile" # TODO: Implement

# TODO: Analyze = Speedup + Profile command
# TODO: All = Check + Speedup + Profile command

# Clean command
cli
    .command 'clean'
    .alias 'C'
    .description "Remove all executables in the directory"
    .action -> console.log "Clean"

cli.help() if cli.notEnoughArguments
replaceSecondAlias()
checkCommandExists()

cli.parse process.argv
{'fraction_non_alphanumeric': 0.1324110671936759, 'fraction_numerical': 0.0003040437823046519, 'mean_word_length': 3.1403398363750785, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, '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': '2043262', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1882, 'n_words': 669}