Current section

6 Versions

Jump to

Compare versions

8 files changed
+122 additions
-22 deletions
  @@ -4,6 +4,27 @@ A process manager for your `Procfile`(s).
4 4
5 5 ## Installation
6 6
7 + Add the following to your deps in `mix.env`
8 +
7 9 ```shell
8 - mix escript.install hex honcho
10 + {:honcho, "~> 0.2"},
9 11 ```
12 +
13 + Add a file `Procfile` to your project. Procfiles are defined in the following
14 + format:
15 +
16 + ```procfile
17 + <process name>: <command>
18 + ```
19 +
20 + ## Usage
21 +
22 + Honcho will add several mix tasks your your project, including:
23 +
24 + * `mix honcho.info` - prints information about your process definitions
25 + * `mix honcho.start` - will start your process
26 +
27 + These tasks take the following optional arguments:
28 +
29 + * `-p, --procfile` - a path to a Procfile. This defaults to a file, `Procfile`,
30 + in the current working directory.
  @@ -4,23 +4,25 @@
4 4 {<<"elixir">>,<<"~> 1.9">>}.
5 5 {<<"files">>,
6 6 [<<"lib">>,<<"lib/honcho.ex">>,<<"lib/mix">>,<<"lib/mix/tasks">>,
7 - <<"lib/mix/tasks/git">>,<<"lib/mix/tasks/git/tags">>,
8 - <<"lib/mix/tasks/git/tags/create.ex">>,<<"lib/mix/tasks/git/tags/push.ex">>,
9 - <<"lib/honcho">>,<<"lib/honcho/error.ex">>,<<"lib/honcho/color.ex">>,
7 + <<"lib/mix/tasks/honcho">>,<<"lib/mix/tasks/honcho/start.ex">>,
8 + <<"lib/mix/tasks/honcho/info.ex">>,<<"lib/mix/tasks/git">>,
9 + <<"lib/mix/tasks/git/tags">>,<<"lib/mix/tasks/git/tags/create.ex">>,
10 + <<"lib/mix/tasks/git/tags/push.ex">>,<<"lib/honcho">>,
11 + <<"lib/honcho/error.ex">>,<<"lib/honcho/color.ex">>,
10 12 <<"lib/honcho/command.ex">>,<<"lib/honcho/subcommand.ex">>,
11 13 <<"lib/honcho/output.ex">>,<<"lib/honcho/subcommand">>,
12 14 <<"lib/honcho/subcommand/start.ex">>,<<"lib/honcho/subcommand/help.ex">>,
13 15 <<"lib/honcho/subcommand/info.ex">>,<<"lib/honcho/command">>,
14 16 <<"lib/honcho/command/init.ex">>,<<"lib/honcho/command/helpers.ex">>,
15 - <<"lib/honcho/procfile.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
16 - <<"README.md">>]}.
17 + <<"lib/honcho/procfile.ex">>,<<"lib/honcho/args.ex">>,<<".formatter.exs">>,
18 + <<"mix.exs">>,<<"README.md">>]}.
17 19 {<<"licenses">>,[<<"MIT">>]}.
18 - {<<"links">>,[{<<"GitHub">>,<<"https://github.com/livinginthepast/honcho">>}]}.
20 + {<<"links">>,[{<<"github">>,<<"https://github.com/livinginthepast/honcho">>}]}.
19 21 {<<"name">>,<<"honcho">>}.
20 22 {<<"requirements">>,
21 23 [[{<<"app">>,<<"honcho_supervisor">>},
22 24 {<<"name">>,<<"honcho_supervisor">>},
23 25 {<<"optional">>,false},
24 26 {<<"repository">>,<<"hexpm">>},
25 - {<<"requirement">>,<<"0.1.0">>}]]}.
26 - {<<"version">>,<<"0.1.0">>}.
27 + {<<"requirement">>,<<"0.2.0">>}]]}.
28 + {<<"version">>,<<"0.2.0">>}.
  @@ -10,13 +10,13 @@ defmodule Honcho do
10 10
11 11 cmd
12 12 |> Honcho.Subcommand.find()
13 - |> run(parse_args(args))
13 + |> run(Honcho.Args.parse(args))
14 14 end
15 15
16 16 def run(_, {:error, :parse_args, arg}),
17 17 do: usage("Unknown option: #{arg}")
18 18
19 - def run({:ok, cmd}, args), do: apply(cmd, :run, args)
19 + def run({:ok, cmd}, {:ok, args}), do: apply(cmd, :run, args)
20 20
21 21 def run({:error, :no_command, cmd}, _),
22 22 do: usage("Unable to find subcommand #{inspect(cmd)}")
  @@ -25,13 +25,4 @@ defmodule Honcho do
25 25 Honcho.Output.warn(msg)
26 26 Honcho.Output.usage()
27 27 end
28 -
29 - defp parse_args(args), do: parse_args(Keyword.new(), args)
30 - defp parse_args(argument_list, []), do: argument_list
31 -
32 - defp parse_args(argument_list, ["--procfile", procfile | tail]),
33 - do: parse_args([Keyword.put(argument_list, :procfile, procfile)], tail)
34 -
35 - defp parse_args(_argument_list, [key | _]),
36 - do: {:error, :parse_args, key}
37 28 end
  @@ -0,0 +1,15 @@
1 + defmodule Honcho.Args do
2 + @moduledoc false
3 +
4 + def parse(args), do: parse(Keyword.new(), args)
5 + def parse(argument_list, []), do: {:ok, argument_list}
6 +
7 + def parse(argument_list, ["-p", procfile | tail]),
8 + do: parse(Keyword.put(argument_list, :procfile, procfile), tail)
9 +
10 + def parse(argument_list, ["--procfile", procfile | tail]),
11 + do: parse(Keyword.put(argument_list, :procfile, procfile), tail)
12 +
13 + def parse(_argument_list, [key | _]),
14 + do: {:error, :parse_args, key}
15 + end
  @@ -6,6 +6,9 @@ defmodule Honcho.Subcommand.Start do
6 6 def run([{:procfile, file} | _]) when is_binary(file),
7 7 do: Honcho.Procfile.read(file) |> run()
8 8
9 + def run(args) when is_list(args),
10 + do: @default_args |> Keyword.merge(args) |> run()
11 +
9 12 def run({:ok, commands}),
10 13 do: Honcho.Command.Init.run(commands) |> run()
Loading more files…