Skip to content

Commit e963ea0

Browse files
committed
chore: fix warnings around installers
1 parent 8d412ce commit e963ea0

File tree

3 files changed

+78
-12
lines changed

3 files changed

+78
-12
lines changed

lib/mix/tasks/ash_postgres.gen.resources.ex

+3-4
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ if Code.ensure_loaded?(Igniter) do
7777
end
7878

7979
@impl Igniter.Mix.Task
80-
def igniter(igniter, argv) do
80+
def igniter(igniter) do
8181
Mix.Task.run("compile")
8282

83-
{%{domain: domain}, argv} = positional_args!(argv)
83+
options = igniter.args.options
84+
domain = igniter.args.positional.domain
8485

8586
domain = Igniter.Project.Module.parse(domain)
8687

87-
options = options!(argv)
88-
8988
repos =
9089
case options[:repo] do
9190
[] ->

lib/mix/tasks/ash_postgres.install.ex

+9-8
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ if Code.ensure_loaded?(Igniter) do
2121
end
2222

2323
@impl true
24-
def igniter(igniter, argv) do
25-
opts = options!(argv)
24+
def igniter(igniter) do
25+
argv = igniter.args.argv
26+
opts = igniter.args.options
2627

2728
repo =
2829
case opts[:repo] do
@@ -465,22 +466,22 @@ if Code.ensure_loaded?(Igniter) do
465466
notice =
466467
if min_pg_version do
467468
"""
468-
A `min_pg_version/0` function has been defined
469+
A `min_pg_version/0` function has been defined
469470
in `#{inspect(repo)}` as `#{min_pg_version}`.
470471
471472
This was based on running `postgres -V`.
472473
473-
You may wish to update this configuration. It should
474-
be set to the lowest version that your application
474+
You may wish to update this configuration. It should
475+
be set to the lowest version that your application
475476
expects to be run against.
476477
"""
477478
else
478479
"""
479-
A `min_pg_version/0` function has been defined in
480+
A `min_pg_version/0` function has been defined in
480481
`#{inspect(repo)}` automatically.
481482
482-
You may wish to update this configuration. It should
483-
be set to the lowest version that your application
483+
You may wish to update this configuration. It should
484+
be set to the lowest version that your application
484485
expects to be run against.
485486
"""
486487
end
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
defmodule Mix.Tasks.AshPostgres.SetupVector.Docs do
2+
@moduledoc false
3+
4+
def short_doc do
5+
"Sets up pgvector for AshPostgres"
6+
end
7+
8+
def example do
9+
"mix ash_postgres.setup_vector"
10+
end
11+
12+
def long_doc do
13+
"""
14+
#{short_doc()}
15+
16+
## Example
17+
18+
```bash
19+
#{example()}
20+
```
21+
"""
22+
end
23+
end
24+
25+
if Code.ensure_loaded?(Igniter) do
26+
defmodule Mix.Tasks.AshPostgres.SetupVector do
27+
@shortdoc "#{__MODULE__.Docs.short_doc()}"
28+
29+
@moduledoc __MODULE__.Docs.long_doc()
30+
31+
use Igniter.Mix.Task
32+
33+
@impl Igniter.Mix.Task
34+
def info(_argv, _composing_task) do
35+
%Igniter.Mix.Task.Info{
36+
group: :ash_postgres,
37+
example: __MODULE__.Docs.example()
38+
}
39+
end
40+
41+
@impl Igniter.Mix.Task
42+
def igniter(igniter) do
43+
# Do your work here and return an updated igniter
44+
igniter
45+
# |> Igniter.add_warning("mix ash_postgres.setup_vector is not yet implemented")
46+
end
47+
end
48+
else
49+
defmodule Mix.Tasks.AshPostgres.SetupVector do
50+
@shortdoc "#{__MODULE__.Docs.short_doc()} | Install `igniter` to use"
51+
52+
@moduledoc __MODULE__.Docs.long_doc()
53+
54+
use Mix.Task
55+
56+
def run(_argv) do
57+
Mix.shell().error("""
58+
The task 'ash_postgres.setup_vector' requires igniter. Please install igniter and try again.
59+
60+
For more information, see: https://hexdocs.pm/igniter/readme.html#installation
61+
""")
62+
63+
exit({:shutdown, 1})
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)