Commit c52c465
Name the commands after the endpoints they are
The first cut invented a second vocabulary: set-property, add-to-property,
rename-class, add-use, set-extends. Half of those rename an endpoint that
already had a name, which means anyone who knows the PHP API has to learn
the CLI's dialect of it too. The directive system was sitting right there
and maps onto flags almost exactly.
So a command named after an endpoint is now that endpoint. Same
arguments, same directives as flags, same result: `archetype property
<target> fillable nickname --add` is `$file->add()->property('fillable',
'nickname')`. Give a value and it writes, give none and it reads.
property className extends implements namespace use useTrait
classConstant methodNames make
fillable hidden visible guarded unguarded casts dates table
connection timestamps
hasOne hasMany belongsTo belongsToMany
Operations with names of their own are the ones with no PHP equivalent —
inspect, show, find, set-array-key, add-case, the method operations,
apply, and the seven relationship types LaravelFile does not cover. The
operation map prints in those two halves so the rule is visible rather
than documented somewhere else.
Two tests hold the line: every operation listed as an endpoint must be a
real method on LaravelFile, and `archetype hasMany <target> Task` must
produce byte-identical output to `$file->hasMany('Task')`. With no
options given the relationship commands call the endpoint rather than
reimplementing it.
Two bugs fell out of the rewrite, both from reading a value off a file
that already carried a directive — the endpoints read directives off the
file, so `$file->add()->use()` as a getter appends instead of answering.
State is now read from the syntax tree, and directives are applied at the
write itself. The second was mine from the first cut: useTrait() answers
with Node\Name objects, so class_basename() on them returned "Name" and
the already-uses check never matched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AjUMv5rFTVJMr6F1J7bx7x1 parent b734d9e commit c52c465
44 files changed
Lines changed: 1925 additions & 1399 deletions
File tree
- src/Console
- Commands
- Concerns
- Support
- tests/Feature/Console
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
| |||
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | 53 | | |
48 | 54 | | |
49 | | - | |
50 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
0 commit comments