From e088b0ef3f7d76e7b7a81db9594524392147c596 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 11 Jun 2023 19:37:19 +0100 Subject: Rename ShedcCli to ShedCli --- .../java/org/shedlang/compiler/cli/ShedCli.java | 45 ++++++++++++++++++++++ .../java/org/shedlang/compiler/cli/ShedcCli.java | 45 ---------------------- 2 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 src/main/java/org/shedlang/compiler/cli/ShedCli.java delete mode 100644 src/main/java/org/shedlang/compiler/cli/ShedcCli.java (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/cli/ShedCli.java b/src/main/java/org/shedlang/compiler/cli/ShedCli.java new file mode 100644 index 00000000..e4955200 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/cli/ShedCli.java @@ -0,0 +1,45 @@ +package org.shedlang.compiler.cli; + +import net.sourceforge.argparse4j.ArgumentParsers; +import net.sourceforge.argparse4j.inf.ArgumentParserException; +import net.sourceforge.argparse4j.inf.Namespace; +import org.shedlang.compiler.ShedCompiler; +import org.shedlang.compiler.errors.SourceError; + +import java.io.IOException; +import java.nio.file.Paths; + +public class ShedCli { + public static void main(String[] rawArgs) throws IOException { + var args = parseArgs(rawArgs); + try { + compile(args); + } catch (SourceError error) { + System.err.println(error.getSource().describe()); + System.err.println(error.getMessage()); + System.exit(2); + } + } + + private static void compile(Namespace args) throws IOException { + var sourcePath = Paths.get(args.getString("source")); + + var compiler = new ShedCompiler(); + compiler.compile(sourcePath); + } + + private static Namespace parseArgs(String[] args) { + var parser = ArgumentParsers.newFor("shed").build() + .defaultHelp(true); + + parser.addArgument("source").required(true); + + try { + return parser.parseArgs(args); + } catch (ArgumentParserException e) { + parser.handleError(e); + System.exit(1); + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/org/shedlang/compiler/cli/ShedcCli.java b/src/main/java/org/shedlang/compiler/cli/ShedcCli.java deleted file mode 100644 index 82549f97..00000000 --- a/src/main/java/org/shedlang/compiler/cli/ShedcCli.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.shedlang.compiler.cli; - -import net.sourceforge.argparse4j.ArgumentParsers; -import net.sourceforge.argparse4j.inf.ArgumentParserException; -import net.sourceforge.argparse4j.inf.Namespace; -import org.shedlang.compiler.ShedCompiler; -import org.shedlang.compiler.errors.SourceError; - -import java.io.IOException; -import java.nio.file.Paths; - -public class ShedcCli { - public static void main(String[] rawArgs) throws IOException { - var args = parseArgs(rawArgs); - try { - compile(args); - } catch (SourceError error) { - System.err.println(error.getSource().describe()); - System.err.println(error.getMessage()); - System.exit(2); - } - } - - private static void compile(Namespace args) throws IOException { - var sourcePath = Paths.get(args.getString("source")); - - var compiler = new ShedCompiler(); - compiler.compile(sourcePath); - } - - private static Namespace parseArgs(String[] args) { - var parser = ArgumentParsers.newFor("shedc").build() - .defaultHelp(true); - - parser.addArgument("source").required(true); - - try { - return parser.parseArgs(args); - } catch (ArgumentParserException e) { - parser.handleError(e); - System.exit(1); - throw new RuntimeException(e); - } - } -} -- cgit v1.2.3