<commit_before>package au.gov.dva.sopapi.client;

import au.gov.dva.sopapi.dtos.QueryParamLabels;
import au.gov.dva.sopapi.dtos.sopref.OperationsResponseDto;
import org.apache.commons.cli.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDate;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Main {

    public static void main(String[] args)
    {
        // todo:
        // - parse command line options
        // - instantiate SoPApiClient with correct URL
        // - execute SoPApiClient methods and print results to console

        Options options = getOptions();
        CommandLineParser parser = new DefaultParser();

        try {
            CommandLine cmd = parser.parse(options, args);

            URL serverUrl = new URL(cmd.getOptionValue("url"));
            String service = cmd.getOptionValue("service");

            SoPApiClient client = new SoPApiClient(serverUrl, service);
            String result = "";

            switch (service) {
                case "getOperations":
                    LocalDate declaredAfterDate = LocalDate.parse(cmd.getOptionValue(QueryParamLabels.QUERY_DATE));
                    OperationsResponseDto operationsResponse = client.getOperations(declaredAfterDate).get();
                    result = OperationsResponseDto.toJsonString(operationsResponse);
                    break;
                default:
                    break;
            }

            System.out.println(result);
        } catch (ParseException e) {
            printHelp(options);
            System.out.println(e);
        } catch (MalformedURLException e) {
            System.out.println(e);
        } catch (InterruptedException e) {
            System.out.println(e);
        } catch (ExecutionException e) {
            System.out.println(e);
        } finally {
            System.exit(-1);
        }
    }

    private static void printHelp(Options options) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("dva-sop-api", options);
    }

    private static Options getOptions() {
        Options options = new Options();

        // Common options
        Option serviceOption = new Option("service", true,
                "Name of the service to call.");
        serviceOption.setRequired(true);

        Option urlOption = new Option("url", true,
                "URL of the server that the API is running on.");
        urlOption.setRequired(true);

        // getOperations options
        Option declaredAfterOption = new Option("declaredAfter", true,
                "Find operations declared after this ISO local date (yyyy-mm-dd).");
        declaredAfterOption.setRequired(true);

        options.addOption(serviceOption);
        options.addOption(urlOption);
        options.addOption(declaredAfterOption);

        return options;
    }

}<commit_msg>Replaced string with reference to QueryParamLabels<commit_after>package au.gov.dva.sopapi.client;

import au.gov.dva.sopapi.dtos.QueryParamLabels;
import au.gov.dva.sopapi.dtos.sopref.OperationsResponseDto;
import org.apache.commons.cli.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDate;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Main {

    public static void main(String[] args)
    {
        // todo:
        // - parse command line options
        // - instantiate SoPApiClient with correct URL
        // - execute SoPApiClient methods and print results to console

        Options options = getOptions();
        CommandLineParser parser = new DefaultParser();

        try {
            CommandLine cmd = parser.parse(options, args);

            URL serverUrl = new URL(cmd.getOptionValue("url"));
            String service = cmd.getOptionValue("service");

            SoPApiClient client = new SoPApiClient(serverUrl, service);
            String result = "";

            switch (service) {
                case "getOperations":
                    LocalDate declaredAfterDate = LocalDate.parse(cmd.getOptionValue(QueryParamLabels.QUERY_DATE));
                    OperationsResponseDto operationsResponse = client.getOperations(declaredAfterDate).get();
                    result = OperationsResponseDto.toJsonString(operationsResponse);
                    break;
                default:
                    break;
            }

            System.out.println(result);
        } catch (ParseException e) {
            printHelp(options);
            System.out.println(e);
        } catch (MalformedURLException e) {
            System.out.println(e);
        } catch (InterruptedException e) {
            System.out.println(e);
        } catch (ExecutionException e) {
            System.out.println(e);
        } finally {
            System.exit(-1);
        }
    }

    private static void printHelp(Options options) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("dva-sop-api", options);
    }

    private static Options getOptions() {
        Options options = new Options();

        // Common options
        Option serviceOption = new Option("service", true,
                "Name of the service to call.");
        serviceOption.setRequired(true);

        Option urlOption = new Option("url", true,
                "URL of the server that the API is running on.");
        urlOption.setRequired(true);

        // getOperations options
        Option declaredAfterOption = new Option(QueryParamLabels.QUERY_DATE, true,
                "Find operations declared after this ISO local date (yyyy-mm-dd).");
        declaredAfterOption.setRequired(true);

        options.addOption(serviceOption);
        options.addOption(urlOption);
        options.addOption(declaredAfterOption);

        return options;
    }

}
{'fraction_non_alphanumeric': 0.09366066924499748, 'fraction_numerical': 0.00033630401883302503, 'mean_word_length': 2.216873985938345, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2556359', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1482, 'n_words': 357}