Skip to content

Commit 2771e03

Browse files
committed
refactor: rename --use_fragments to --fragments and remove -f alias
1 parent 7874074 commit 2771e03

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if Code.ensure_loaded?(Igniter) do
3434
- `public` - Mark all attributes and relationships as `public? true`. Defaults to `true`.
3535
- `no-migrations` - Do not generate snapshots & migrations for the resources. Defaults to `false`.
3636
- `skip-unknown` - Skip any attributes with types that we don't have a corresponding Elixir type for, and relationships that we can't assume the name of.
37-
- `use-fragments`, `f` - Generate attributes and relationships in a separate fragment file. This allows the fragment to be regenerated without affecting user customizations in the main resource file. Defaults to `false`.
37+
- `fragments` - Generate attributes and relationships in a separate fragment file. This allows the fragment to be regenerated without affecting user customizations in the main resource file. Defaults to `false`.
3838
3939
## Tables
4040
@@ -63,22 +63,21 @@ if Code.ensure_loaded?(Igniter) do
6363
migrations: :boolean,
6464
snapshots_only: :boolean,
6565
domain: :keep,
66-
use_fragments: :boolean
66+
fragments: :boolean
6767
],
6868
aliases: [
6969
t: :tables,
7070
y: :boolean,
7171
r: :repo,
7272
e: :extend,
7373
d: :domain,
74-
s: :skip_tables,
75-
f: :use_fragments
74+
s: :skip_tables
7675
],
7776
defaults: [
7877
default_actions: true,
7978
migrations: true,
8079
public: true,
81-
use_fragments: false
80+
fragments: false
8281
]
8382
}
8483
end

lib/resource_generator/resource_generator.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if Code.ensure_loaded?(Igniter) do
7676
|> Spec.add_relationships(resources, opts)
7777

7878
Enum.reduce(specs, igniter, fn table_spec, igniter ->
79-
if opts[:use_fragments] do
79+
if opts[:fragments] do
8080
table_to_resource_with_fragment(igniter, table_spec, domain, opts)
8181
else
8282
table_to_resource(igniter, table_spec, domain, opts)

test/resource_generator_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ defmodule AshPostgres.ResourceGeenratorTests do
197197
""")
198198
end
199199

200-
describe "--use_fragments option" do
201-
@describetag :use_fragments
200+
describe "--fragments option" do
201+
@describetag :fragments
202202

203203
test "generates resource and fragment files when resource does not exist" do
204204
test_project()
@@ -209,7 +209,7 @@ defmodule AshPostgres.ResourceGeenratorTests do
209209
"--yes",
210210
"--repo",
211211
"AshPostgres.TestRepo",
212-
"--use-fragments"
212+
"--fragments"
213213
])
214214
|> assert_creates("lib/my_app/accounts/example_table.ex", """
215215
defmodule MyApp.Accounts.ExampleTable do
@@ -255,7 +255,7 @@ defmodule AshPostgres.ResourceGeenratorTests do
255255
""")
256256
end
257257

258-
@tag :use_fragments
258+
@tag :fragments
259259
test "generates fragment with relationships" do
260260
AshPostgres.TestRepo.query!("CREATE SCHEMA IF NOT EXISTS fragtest")
261261

@@ -285,7 +285,7 @@ defmodule AshPostgres.ResourceGeenratorTests do
285285
"--yes",
286286
"--repo",
287287
"AshPostgres.TestRepo",
288-
"--use-fragments"
288+
"--fragments"
289289
])
290290
|> assert_creates("lib/my_app/sales/customer.ex", """
291291
defmodule MyApp.Sales.Customer do
@@ -365,7 +365,7 @@ defmodule AshPostgres.ResourceGeenratorTests do
365365
""")
366366
end
367367

368-
@tag :use_fragments
368+
@tag :fragments
369369
test "only regenerates fragment when resource already exists" do
370370
# Create a pre-existing resource file with user customization
371371
existing_resource = """
@@ -403,7 +403,7 @@ defmodule AshPostgres.ResourceGeenratorTests do
403403
"--yes",
404404
"--repo",
405405
"AshPostgres.TestRepo",
406-
"--use-fragments"
406+
"--fragments"
407407
])
408408
# Resource should NOT be modified (it already exists)
409409
|> assert_unchanged("lib/my_app/accounts/example_table.ex")

0 commit comments

Comments
 (0)