<commit_before>import * as commander from 'commander';
import { ApiContext } from '../api';
import { loadConfig } from '../config';
import { importContest } from './import';

const program = new commander.Command();

function serve() { }

function _export() { }

function show() { }

async function ctxFromConfig(configFile?: string): Promise<ApiContext> {
    const config = loadConfig(configFile);
    const context = new ApiContext(config);
    await context.sequelize.sync();

    return context;
}

program.name('turingarena').version('1.0');

program
    .command('serve')
    .description('start TuringArena server')
    .action(serve);

program
    .command('import [dir]')
    .description('import a contest')
    .option('-c, --config <path>', 'configuration file')
    .action(async (dir, opts) =>
        importContest(await ctxFromConfig(opts.config), dir),
    );<commit_msg>server cli: implement `serve` command<commit_after>import * as commander from 'commander';
import { ApiContext } from '../api';
import { loadConfig } from '../config';
import { serve } from '../server';
import { importContest } from './import';

const program = new commander.Command();

function _export() { }

function show() { }

async function ctxFromConfig(configFile?: string): Promise<ApiContext> {
    const config = loadConfig(configFile);
    const context = new ApiContext(config);
    await context.sequelize.sync();

    return context;
}

program.name('turingarena').version('1.0');

program
    .command('serve')
    .description('start TuringArena server')
    .action(opts => {
        serve(loadConfig(opts.config));
    });

program
    .command('import [dir]')
    .description('import a contest')
    .option('-c, --config <path>', 'configuration file')
    .action(async (dir, opts) =>
        importContest(await ctxFromConfig(opts.config), dir),
    );
{'fraction_non_alphanumeric': 0.15710455764075068, 'fraction_numerical': 0.0021447721179624667, 'mean_word_length': 3.9365079365079363, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '4003083', 'n_tokens_mistral': 540, 'n_tokens_neox': 547, 'n_words': 141}