config/checkstyle/checkstyle.xml
config/checkstyle/suppressions.xml
+ config_loc=${project.basedir}/config/checkstyle
true
true
warning
diff --git a/src/main/java/com/samsonmedia/barn/Main.java b/src/main/java/com/samsonmedia/barn/Main.java
new file mode 100644
index 0000000..1178d8f
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/Main.java
@@ -0,0 +1,41 @@
+package com.samsonmedia.barn;
+
+import com.samsonmedia.barn.cli.BarnCommand;
+
+import picocli.CommandLine;
+
+/**
+ * Main entry point for the Barn application.
+ *
+ * This class initializes the picocli command line parser and delegates
+ * command execution to the appropriate subcommand handlers.
+ */
+public final class Main {
+
+ private Main() {
+ // Utility class - prevent instantiation
+ }
+
+ /**
+ * Main entry point.
+ *
+ * @param args command line arguments
+ */
+ public static void main(String[] args) {
+ int exitCode = run(args);
+ System.exit(exitCode);
+ }
+
+ /**
+ * Executes the command line and returns the exit code.
+ *
+ *
This method is separated from {@link #main(String[])} to enable testing
+ * without calling {@link System#exit(int)}.
+ *
+ * @param args command line arguments
+ * @return the exit code (0 for success, non-zero for failure)
+ */
+ public static int run(String[] args) {
+ return new CommandLine(new BarnCommand()).execute(args);
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/BarnCommand.java b/src/main/java/com/samsonmedia/barn/cli/BarnCommand.java
new file mode 100644
index 0000000..e9faacd
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/BarnCommand.java
@@ -0,0 +1,38 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Root command for the Barn CLI.
+ *
+ *
This command serves as the entry point for all barn operations.
+ * When invoked without a subcommand, it displays usage information.
+ */
+@Command(
+ name = "barn",
+ mixinStandardHelpOptions = true,
+ version = "barn 0.1.0-SNAPSHOT",
+ description = "Cross-platform job daemon for media processing",
+ subcommands = {
+ RunCommand.class,
+ StatusCommand.class,
+ DescribeCommand.class,
+ KillCommand.class,
+ CleanCommand.class,
+ ServiceCommand.class,
+ ConfigCommand.class
+ }
+)
+public class BarnCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ // When no subcommand is specified, show usage
+ spec.commandLine().usage(spec.commandLine().getOut());
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/CleanCommand.java b/src/main/java/com/samsonmedia/barn/cli/CleanCommand.java
new file mode 100644
index 0000000..ff5e29e
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/CleanCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to remove completed jobs.
+ *
+ *
Placeholder implementation - full implementation in ticket #13.
+ */
+@Command(
+ name = "clean",
+ mixinStandardHelpOptions = true,
+ description = "Remove completed jobs"
+)
+public class CleanCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().getOut().println("Clean command not yet implemented");
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/ConfigCommand.java b/src/main/java/com/samsonmedia/barn/cli/ConfigCommand.java
new file mode 100644
index 0000000..8d5d420
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/ConfigCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command for configuration management.
+ *
+ *
Placeholder implementation - full implementation in ticket #21.
+ */
+@Command(
+ name = "config",
+ mixinStandardHelpOptions = true,
+ description = "Configuration management"
+)
+public class ConfigCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().usage(spec.commandLine().getOut());
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/DescribeCommand.java b/src/main/java/com/samsonmedia/barn/cli/DescribeCommand.java
new file mode 100644
index 0000000..58fb277
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/DescribeCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to show detailed information about a specific job.
+ *
+ *
Placeholder implementation - full implementation in ticket #11.
+ */
+@Command(
+ name = "describe",
+ mixinStandardHelpOptions = true,
+ description = "Show detailed job information"
+)
+public class DescribeCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().getOut().println("Describe command not yet implemented");
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/KillCommand.java b/src/main/java/com/samsonmedia/barn/cli/KillCommand.java
new file mode 100644
index 0000000..3e54918
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/KillCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to stop a running job.
+ *
+ *
Placeholder implementation - full implementation in ticket #12.
+ */
+@Command(
+ name = "kill",
+ mixinStandardHelpOptions = true,
+ description = "Stop a running job"
+)
+public class KillCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().getOut().println("Kill command not yet implemented");
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/RunCommand.java b/src/main/java/com/samsonmedia/barn/cli/RunCommand.java
new file mode 100644
index 0000000..7022193
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/RunCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to start a new job.
+ *
+ *
Placeholder implementation - full implementation in ticket #9.
+ */
+@Command(
+ name = "run",
+ mixinStandardHelpOptions = true,
+ description = "Start a new job"
+)
+public class RunCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().getOut().println("Run command not yet implemented");
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/ServiceCommand.java b/src/main/java/com/samsonmedia/barn/cli/ServiceCommand.java
new file mode 100644
index 0000000..ae93900
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/ServiceCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to manage the Barn service.
+ *
+ *
Placeholder implementation - full implementation in ticket #16.
+ */
+@Command(
+ name = "service",
+ mixinStandardHelpOptions = true,
+ description = "Manage the Barn service"
+)
+public class ServiceCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().usage(spec.commandLine().getOut());
+ }
+}
diff --git a/src/main/java/com/samsonmedia/barn/cli/StatusCommand.java b/src/main/java/com/samsonmedia/barn/cli/StatusCommand.java
new file mode 100644
index 0000000..d98c89e
--- /dev/null
+++ b/src/main/java/com/samsonmedia/barn/cli/StatusCommand.java
@@ -0,0 +1,26 @@
+package com.samsonmedia.barn.cli;
+
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Model.CommandSpec;
+import picocli.CommandLine.Spec;
+
+/**
+ * Command to show status of all jobs.
+ *
+ *
Placeholder implementation - full implementation in ticket #10.
+ */
+@Command(
+ name = "status",
+ mixinStandardHelpOptions = true,
+ description = "Show status of all jobs"
+)
+public class StatusCommand implements Runnable {
+
+ @Spec
+ private CommandSpec spec;
+
+ @Override
+ public void run() {
+ spec.commandLine().getOut().println("Status command not yet implemented");
+ }
+}
diff --git a/src/main/java/org/media/samson/Main.java b/src/main/java/org/media/samson/Main.java
deleted file mode 100644
index 52ef3e5..0000000
--- a/src/main/java/org/media/samson/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.media.samson;
-
-//TIP To Run code, press or
-// click the icon in the gutter.
-public class Main {
- static void main() {
- //TIP Press with your caret at the highlighted text
- // to see how IntelliJ IDEA suggests fixing it.
- IO.println(String.format("Hello and welcome!"));
-
- for (int i = 1; i <= 5; i++) {
- //TIP Press to start debugging your code. We have set one breakpoint
- // for you, but you can always add more by pressing .
- IO.println("i = " + i);
- }
- }
-}
diff --git a/src/test/java/com/samsonmedia/barn/MainTest.java b/src/test/java/com/samsonmedia/barn/MainTest.java
new file mode 100644
index 0000000..75f0b37
--- /dev/null
+++ b/src/test/java/com/samsonmedia/barn/MainTest.java
@@ -0,0 +1,91 @@
+package com.samsonmedia.barn;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for the Main entry point.
+ */
+class MainTest {
+
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private final PrintStream originalErr = System.err;
+
+ @BeforeEach
+ void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
+ }
+
+ @AfterEach
+ void restoreStreams() {
+ System.setOut(originalOut);
+ System.setErr(originalErr);
+ }
+
+ @Test
+ void run_withHelpFlag_shouldReturnZeroExitCode() {
+ // Arrange & Act
+ int exitCode = Main.run(new String[]{"--help"});
+
+ // Assert
+ assertThat(exitCode).isZero();
+ }
+
+ @Test
+ void run_withVersionFlag_shouldReturnZeroExitCode() {
+ // Arrange & Act
+ int exitCode = Main.run(new String[]{"--version"});
+
+ // Assert
+ assertThat(exitCode).isZero();
+ }
+
+ @Test
+ void run_withNoArgs_shouldReturnZeroExitCode() {
+ // Arrange & Act
+ int exitCode = Main.run(new String[]{});
+
+ // Assert
+ assertThat(exitCode).isZero();
+ }
+
+ @Test
+ void run_withInvalidCommand_shouldReturnNonZeroExitCode() {
+ // Arrange & Act
+ int exitCode = Main.run(new String[]{"nonexistent-command"});
+
+ // Assert
+ assertThat(exitCode).isNotZero();
+ }
+
+ @Test
+ void run_withHelpFlag_shouldPrintUsageToStdout() {
+ // Arrange & Act
+ Main.run(new String[]{"--help"});
+
+ // Assert
+ String output = outContent.toString();
+ assertThat(output).contains("barn");
+ assertThat(output).contains("Usage:");
+ }
+
+ @Test
+ void run_withVersionFlag_shouldPrintVersionToStdout() {
+ // Arrange & Act
+ Main.run(new String[]{"--version"});
+
+ // Assert
+ String output = outContent.toString();
+ assertThat(output).contains("barn");
+ assertThat(output).contains("0.1.0");
+ }
+}
diff --git a/src/test/java/com/samsonmedia/barn/cli/BarnCommandTest.java b/src/test/java/com/samsonmedia/barn/cli/BarnCommandTest.java
new file mode 100644
index 0000000..a70569b
--- /dev/null
+++ b/src/test/java/com/samsonmedia/barn/cli/BarnCommandTest.java
@@ -0,0 +1,252 @@
+package com.samsonmedia.barn.cli;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import picocli.CommandLine;
+
+/**
+ * Tests for the root BarnCommand.
+ */
+class BarnCommandTest {
+
+ private CommandLine commandLine;
+ private StringWriter outWriter;
+ private StringWriter errWriter;
+
+ @BeforeEach
+ void setUp() {
+ commandLine = new CommandLine(new BarnCommand());
+ outWriter = new StringWriter();
+ errWriter = new StringWriter();
+ commandLine.setOut(new PrintWriter(outWriter));
+ commandLine.setErr(new PrintWriter(errWriter));
+ }
+
+ @Test
+ void help_shouldDisplayCommandName() {
+ // Arrange & Act
+ commandLine.execute("--help");
+
+ // Assert
+ String output = outWriter.toString();
+ assertThat(output).contains("barn");
+ }
+
+ @Test
+ void help_shouldDisplayDescription() {
+ // Arrange & Act
+ commandLine.execute("--help");
+
+ // Assert
+ String output = outWriter.toString();
+ assertThat(output).contains("Cross-platform job daemon");
+ }
+
+ @Test
+ void help_shouldListSubcommands() {
+ // Arrange & Act
+ commandLine.execute("--help");
+
+ // Assert
+ String output = outWriter.toString();
+ assertThat(output).contains("run");
+ assertThat(output).contains("status");
+ assertThat(output).contains("describe");
+ assertThat(output).contains("kill");
+ assertThat(output).contains("clean");
+ assertThat(output).contains("service");
+ assertThat(output).contains("config");
+ }
+
+ @Test
+ void version_shouldDisplayVersionNumber() {
+ // Arrange & Act
+ commandLine.execute("--version");
+
+ // Assert
+ String output = outWriter.toString();
+ assertThat(output).contains("0.1.0");
+ }
+
+ @Test
+ void noArgs_shouldShowUsage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute();
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Usage:");
+ }
+
+ @Test
+ void invalidSubcommand_shouldReturnNonZeroExitCode() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("nonexistent");
+
+ // Assert
+ assertThat(exitCode).isNotZero();
+ }
+
+ @Test
+ void runSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("run", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("run");
+ }
+
+ @Test
+ void statusSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("status", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("status");
+ }
+
+ @Test
+ void describeSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("describe", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("describe");
+ }
+
+ @Test
+ void killSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("kill", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("kill");
+ }
+
+ @Test
+ void cleanSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("clean", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("clean");
+ }
+
+ @Test
+ void serviceSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("service", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("service");
+ }
+
+ @Test
+ void configSubcommand_shouldExist() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("config", "--help");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("config");
+ }
+
+ @Test
+ void runSubcommand_shouldShowNotImplementedMessage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("run");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Run command not yet implemented");
+ }
+
+ @Test
+ void statusSubcommand_shouldShowNotImplementedMessage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("status");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Status command not yet implemented");
+ }
+
+ @Test
+ void describeSubcommand_shouldShowNotImplementedMessage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("describe");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Describe command not yet implemented");
+ }
+
+ @Test
+ void killSubcommand_shouldShowNotImplementedMessage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("kill");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Kill command not yet implemented");
+ }
+
+ @Test
+ void cleanSubcommand_shouldShowNotImplementedMessage() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("clean");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Clean command not yet implemented");
+ }
+
+ @Test
+ void serviceSubcommand_shouldShowUsageByDefault() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("service");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Usage:");
+ assertThat(output).contains("service");
+ }
+
+ @Test
+ void configSubcommand_shouldShowUsageByDefault() {
+ // Arrange & Act
+ int exitCode = commandLine.execute("config");
+
+ // Assert
+ assertThat(exitCode).isZero();
+ String output = outWriter.toString();
+ assertThat(output).contains("Usage:");
+ assertThat(output).contains("config");
+ }
+}