Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit 9b5c392

Browse files
committed
Define standalone as its own main command
This command will be used to manage standalone applications define in the Makinafile
1 parent 5cb3ddc commit 9b5c392

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

lib/makina/cli.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Makina.Cli do
99
init: Commands.Init,
1010
server: Commands.Server,
1111
debug: Commands.Debug,
12-
deploy: Commands.Deploy
12+
standalone: Commands.Standalone
1313
}
1414
end
1515

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
defmodule Makina.Cli.Commands.Deploy do
1+
defmodule Makina.Cli.Commands.Standalone do
22
@behaviour Makina.Cli.Command
33

44
import Makina.Cli.Utils
55

66
alias Makina.IO
77

8-
def name(), do: "deploy"
8+
@sub_commands ~w[deploy]a
9+
10+
def name(), do: "standalone"
911

1012
def short_description(),
11-
do: "Deploys all applications found in a Makinafile according to their definition."
13+
do: "Manage standalone applications defined in the Makinafile"
1214

1315
def help,
1416
do: """
1517
Makina
16-
Deploy command
18+
Standalone applications management command
19+
20+
Manages all standalone applications found in the current Makinafile.
1721
18-
Deploys all applications found in a Makinafile according to their definition.
19-
Applications defined inside a `standalone` block will be deployed independently from
20-
each other and a failure won't affect other deployments.
22+
Usage:
23+
makina standalone <SUB COMMAND> [OPTIONS]
2124
22-
makina deploy [OPTIONS]
25+
Sub-commands:
26+
deploy Deploys all standalone applications defined in the Makinafile.
2327
2428
Options:
2529
* --file - The path to a Makinafile, if not provided the command will look for it in the current folder.
2630
"""
2731

28-
def exec(_arguments, options) do
32+
def exec(arguments, options) do
33+
extract_subcommand(arguments)
34+
|> sub_command(options)
35+
end
36+
37+
def options() do
38+
[file: :string]
39+
end
40+
41+
defp sub_command(:deploy, options) do
2942
ctx =
3043
makinafile(options)
3144
|> fetch_context()
@@ -48,8 +61,10 @@ defmodule Makina.Cli.Commands.Deploy do
4861
:ok
4962
end
5063

51-
def options() do
52-
[file: :string]
64+
defp extract_subcommand([sub_command | _rest]) do
65+
sub_command = sub_command |> String.to_atom()
66+
67+
if Enum.member?(@sub_commands, sub_command), do: sub_command, else: :help
5368
end
5469

5570
defp deployment_errors?(results) do

0 commit comments

Comments
 (0)