Skip to content

Commit 0b40840

Browse files
Ran the formatter and updated the docs. Also removed CI/CD support for Windows.
1 parent 9bf67ec commit 0b40840

33 files changed

Lines changed: 765 additions & 730 deletions

README.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,65 @@ There are a few major changes between this version and the original version.
1111
2. There is an entirely _new_ generator command that is much more flexable than the previous generation. Please read the docs to better understand how to utilize this.
1212

1313

14+
15+
1416
## Installation
1517

16-
1. Add the dependency to your `shard.yml`:
1718

18-
```yaml
19-
dependencies:
20-
amber_cli:
21-
github: amberframework/amber_cli
22-
```
19+
MacOS & Linux via Homebrew:
20+
21+
`brew install amber`
22+
23+
From source:
2324

24-
2. Run `shards install`
25+
1. Clone the repo from the latest release tag `git clone git@
26+
2. Install the dependencies `shards install`
27+
3. Build the binary `crystal build src/amber_cli.cr -o amber`
28+
4. (Optional) Build the MCP server `crystal build src/amber_mcp`
2529

26-
## Usage
2730

28-
```crystal
29-
require "amber_cli"
30-
```
31+
Windows:
32+
33+
Not directly supported at this time. This CLI tool should work as expected when using a virtual machine or WSL2.
34+
3135

3236
TODO: Write usage instructions here
3337

3438
## Development
3539

36-
TODO: Write development instructions here
40+
To get started with development:
41+
42+
1. **Install Crystal**: Make sure you have Crystal installed (version 1.0+ recommended)
43+
- macOS: `brew install crystal`
44+
- Ubuntu/Debian: Follow the [Crystal installation guide](https://crystal-lang.org/install/)
45+
46+
2. **Clone and setup**:
47+
```bash
48+
git clone https://github.com/amberframework/amber_cli.git
49+
cd amber_cli
50+
shards install
51+
```
52+
53+
3. **Build and test**:
54+
```bash
55+
# Build the CLI
56+
crystal build src/amber_cli.cr -o amber
57+
58+
# Run tests
59+
crystal spec
60+
61+
# Run the CLI locally
62+
./amber --help
63+
```
64+
65+
4. **Development workflow**:
66+
- The main CLI entry point is in `src/amber_cli.cr`
67+
- Core functionality is organized under `src/amber_cli/core/`
68+
- Commands are defined in `src/amber_cli/commands/`
69+
- Run `crystal run src/amber_cli.cr -- <args>` to test changes without building
70+
71+
5. **Code style**: Follow Crystal's standard formatting with `crystal tool format`
72+
3773

3874
## Contributing
3975

spec/amber_cli_spec.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module SpecHelper
4040
def self.within_temp_directory(&block)
4141
temp_dir = create_temp_directory
4242
original_dir = Dir.current
43-
43+
4444
begin
4545
Dir.cd(temp_dir)
4646
yield temp_dir
@@ -63,10 +63,10 @@ describe "Amber CLI New Architecture" do
6363
# Test that all our new classes can be instantiated
6464
transformer = AmberCLI::Core::WordTransformer
6565
engine = AmberCLI::Core::TemplateEngine.new
66-
66+
6767
transformer.should_not be_nil
6868
engine.should_not be_nil
69-
69+
7070
# Basic functionality test
7171
result = transformer.transform("user", "pascal_case")
7272
result.should eq("User")

spec/commands/base_command_spec.cr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ describe AmberCLI::Core::BaseCommand do
6464
it "parses simple flags correctly" do
6565
command = TestGenerateCommand.new("generate")
6666
args = ["model", "User", "--force", "--verbose"]
67-
67+
6868
# Mock parse_and_execute to not actually execute
6969
command.option_parser.unknown_args do |unknown_args, _|
7070
command.remaining_arguments.concat(unknown_args)
7171
end
7272
command.option_parser.parse(args)
73-
73+
7474
command.parsed_options["force"].should be_true
7575
command.parsed_options["verbose"].should be_true
7676
command.remaining_arguments.should eq(["model", "User"])
@@ -79,12 +79,12 @@ describe AmberCLI::Core::BaseCommand do
7979
it "parses arguments with values" do
8080
command = TestGenerateCommand.new("generate")
8181
args = ["controller", "Users", "--template", "custom_controller", "--force"]
82-
82+
8383
command.option_parser.unknown_args do |unknown_args, _|
8484
command.remaining_arguments.concat(unknown_args)
8585
end
8686
command.option_parser.parse(args)
87-
87+
8888
command.parsed_options["template"].should eq("custom_controller")
8989
command.parsed_options["force"].should be_true
9090
command.remaining_arguments.should eq(["controller", "Users"])
@@ -93,12 +93,12 @@ describe AmberCLI::Core::BaseCommand do
9393
it "handles mixed short and long options" do
9494
command = TestGenerateCommand.new("generate")
9595
args = ["scaffold", "Post", "-f", "--template", "blog_scaffold", "-v"]
96-
96+
9797
command.option_parser.unknown_args do |unknown_args, _|
9898
command.remaining_arguments.concat(unknown_args)
9999
end
100100
command.option_parser.parse(args)
101-
101+
102102
command.parsed_options["force"].should be_true
103103
command.parsed_options["verbose"].should be_true
104104
command.parsed_options["template"].should eq("blog_scaffold")
@@ -108,12 +108,12 @@ describe AmberCLI::Core::BaseCommand do
108108
it "preserves non-option arguments in order" do
109109
command = TestNewCommand.new("new")
110110
args = ["my_app", "--database", "postgresql", "extra_arg"]
111-
111+
112112
command.option_parser.unknown_args do |unknown_args, _|
113113
command.remaining_arguments.concat(unknown_args)
114114
end
115115
command.option_parser.parse(args)
116-
116+
117117
command.parsed_options["database"].should eq("postgresql")
118118
command.remaining_arguments.should eq(["my_app", "extra_arg"])
119119
end
@@ -122,25 +122,25 @@ describe AmberCLI::Core::BaseCommand do
122122
context "with edge cases" do
123123
it "handles empty argument list" do
124124
command = TestGenerateCommand.new("generate")
125-
125+
126126
command.option_parser.unknown_args do |unknown_args, _|
127127
command.remaining_arguments.concat(unknown_args)
128128
end
129129
command.option_parser.parse([] of String)
130-
130+
131131
command.parsed_options.should be_empty
132132
command.remaining_arguments.should be_empty
133133
end
134134

135135
it "handles only flags with no arguments" do
136136
command = TestGenerateCommand.new("generate")
137137
args = ["--force", "--verbose"]
138-
138+
139139
command.option_parser.unknown_args do |unknown_args, _|
140140
command.remaining_arguments.concat(unknown_args)
141141
end
142142
command.option_parser.parse(args)
143-
143+
144144
command.parsed_options["force"].should be_true
145145
command.parsed_options["verbose"].should be_true
146146
command.remaining_arguments.should be_empty
@@ -149,12 +149,12 @@ describe AmberCLI::Core::BaseCommand do
149149
it "handles arguments without any flags" do
150150
command = TestGenerateCommand.new("generate")
151151
args = ["model", "User", "name:string", "email:string"]
152-
152+
153153
command.option_parser.unknown_args do |unknown_args, _|
154154
command.remaining_arguments.concat(unknown_args)
155155
end
156156
command.option_parser.parse(args)
157-
157+
158158
command.parsed_options.should be_empty
159159
command.remaining_arguments.should eq(["model", "User", "name:string", "email:string"])
160160
end
@@ -164,12 +164,12 @@ describe AmberCLI::Core::BaseCommand do
164164
describe "option access methods" do
165165
it "provides access to parsed options" do
166166
command = TestGenerateCommand.new("generate")
167-
167+
168168
command.option_parser.unknown_args do |unknown_args, _|
169169
command.remaining_arguments.concat(unknown_args)
170170
end
171171
command.option_parser.parse(["--force", "--template", "custom"])
172-
172+
173173
command.parsed_options["force"].should be_true
174174
command.parsed_options["template"].should eq("custom")
175175
end
@@ -187,15 +187,15 @@ describe AmberCLI::Core::CommandRegistry do
187187
describe ".register" do
188188
it "registers a command class successfully" do
189189
AmberCLI::Core::CommandRegistry.register("test_generate", ["tg"], TestGenerateCommand)
190-
190+
191191
AmberCLI::Core::CommandRegistry.find_command("test_generate").should eq(TestGenerateCommand)
192192
AmberCLI::Core::CommandRegistry.find_command("tg").should eq(TestGenerateCommand)
193193
end
194194

195195
it "allows multiple command registrations" do
196196
AmberCLI::Core::CommandRegistry.register("test_generate2", ["tg2"], TestGenerateCommand)
197197
AmberCLI::Core::CommandRegistry.register("test_new2", ["tn2"], TestNewCommand)
198-
198+
199199
AmberCLI::Core::CommandRegistry.find_command("test_generate2").should eq(TestGenerateCommand)
200200
AmberCLI::Core::CommandRegistry.find_command("test_new2").should eq(TestNewCommand)
201201
end
@@ -204,7 +204,7 @@ describe AmberCLI::Core::CommandRegistry do
204204
describe ".find_command" do
205205
it "returns command class for registered commands" do
206206
AmberCLI::Core::CommandRegistry.register("test_find", ["tf"], TestGenerateCommand)
207-
207+
208208
AmberCLI::Core::CommandRegistry.find_command("test_find").should eq(TestGenerateCommand)
209209
end
210210

@@ -214,7 +214,7 @@ describe AmberCLI::Core::CommandRegistry do
214214

215215
it "works with aliases" do
216216
AmberCLI::Core::CommandRegistry.register("test_alias", ["ta", "talias"], TestGenerateCommand)
217-
217+
218218
AmberCLI::Core::CommandRegistry.find_command("test_alias").should eq(TestGenerateCommand)
219219
AmberCLI::Core::CommandRegistry.find_command("ta").should eq(TestGenerateCommand)
220220
AmberCLI::Core::CommandRegistry.find_command("talias").should eq(TestGenerateCommand)
@@ -226,13 +226,13 @@ describe AmberCLI::Core::CommandRegistry do
226226
# Clear any existing commands for this test
227227
AmberCLI::Core::CommandRegistry.register("test_list1", ["tl1"], TestGenerateCommand)
228228
AmberCLI::Core::CommandRegistry.register("test_list2", ["tl2"], TestNewCommand)
229-
229+
230230
commands = AmberCLI::Core::CommandRegistry.list_commands
231-
231+
232232
commands.should contain("test_list1")
233233
commands.should contain("test_list2")
234234
commands.should contain("tl1")
235235
commands.should contain("tl2")
236236
end
237237
end
238-
end
238+
end

0 commit comments

Comments
 (0)