From 96c2c909ba7ec21a8eb349ef3902c68f9fa834a4 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 25 Jan 2025 17:08:32 +0000 Subject: Set source as path in CLI args --- src/main/java/org/shedlang/compiler/cli/ShedCli.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (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 index 6e5d115b..c311e7bd 100644 --- a/src/main/java/org/shedlang/compiler/cli/ShedCli.java +++ b/src/main/java/org/shedlang/compiler/cli/ShedCli.java @@ -1,6 +1,7 @@ package org.shedlang.compiler.cli; import net.sourceforge.argparse4j.ArgumentParsers; +import net.sourceforge.argparse4j.ext.java7.PathArgumentType; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import org.shedlang.compiler.ShedCompiler; @@ -8,6 +9,7 @@ import org.shedlang.compiler.backends.Backends; import org.shedlang.compiler.errors.CompilerError; import java.io.IOException; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; @@ -24,7 +26,7 @@ public class ShedCli { } private static void compile(Namespace args) throws IOException, InterruptedException { - var sourcePath = Paths.get(args.getString("source")); + var sourcePath = args.get("source"); var compiler = new ShedCompiler(); @@ -45,7 +47,10 @@ public class ShedCli { var compileSubParser = subparsers.addParser("compile"); compileSubParser.setDefault("command", Command.COMPILE); - compileSubParser.addArgument("source").required(true); + compileSubParser + .addArgument("source") + .type(new PathArgumentType()) + .required(true); compileSubParser.addArgument("--target").choices(Backends.targetNames()).required(true); compileSubParser.addArgument("--profile").required(false); -- cgit v1.2.3