Skip to content

Commit d9367a0

Browse files
authored
Format README, format Ruby code, add .clangd file to specify C2x for LSP clangd (#4)
1 parent 022b019 commit d9367a0

File tree

4 files changed

+56
-39
lines changed

4 files changed

+56
-39
lines changed

.clangd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CompileFlags:
2+
Add: ["--std=c2x"]
3+
Compiler: gcc

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [0.0.4] - 2025-03-11
99

1010
### Added
11+
1112
- Directory-level configuration with `.nutshell.json` files
1213
- Configuration hierarchy: directory configs override user configs which override system configs
1314
- Automatic config reloading when changing directories with `cd`
1415
- Project-specific aliases and settings through directory configs
1516
- Support for different themes per project
1617

1718
### Fixed
19+
1820
- Memory leak in directory path traversal
19-
- Config loading order to properly respect precedence rules
21+
- Config loading order to properly respect precedence rules

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ cd nutshell
3131
make
3232
```
3333

34-
### Installing
34+
### Installing
3535

3636
#### Via Homebrew (macOS & Linux)
37+
3738
```bash
3839
# If using the formula directly
3940
brew install --build-from-source ./nutshell.rb
@@ -44,15 +45,19 @@ brew install nutshell
4445
```
4546

4647
#### System-wide installation (requires sudo)
48+
4749
```bash
4850
sudo make install
4951
```
5052

5153
#### User-level installation
54+
5255
```bash
5356
make install-user
5457
```
58+
5559
Then add `$HOME/bin` to your PATH if it's not already there:
60+
5661
```bash
5762
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc # or ~/.zshrc or ~/.bash_profile
5863
```
@@ -85,11 +90,13 @@ Nutshell includes AI features to help with shell commands:
8590

8691
1. Get an OpenAI API key from [OpenAI Platform](https://platform.openai.com/)
8792
2. Set your API key:
93+
8894
```bash
8995
🥜 ~ ➜ set-api-key YOUR_API_KEY
9096
```
91-
97+
9298
Alternatively, set it as an environment variable:
99+
93100
```bash
94101
export OPENAI_API_KEY=your_api_key
95102
```
@@ -303,11 +310,13 @@ NUT_DEBUG=1 NUT_DEBUG_THEME=1 NUT_DEBUG_PARSER=1 NUT_DEBUG_EXEC=1 NUT_DEBUG_REGI
303310
## Creating Packages
304311

305312
Packages are directories containing:
313+
306314
- `manifest.json`: Package metadata
307315
- `[package-name].sh`: Main executable script
308316
- Additional files as needed
309317

310318
Example manifest.json:
319+
311320
```json
312321
{
313322
"name": "mypackage",
@@ -320,6 +329,7 @@ Example manifest.json:
320329
```
321330

322331
Generate a checksum for your package with:
332+
323333
```bash
324334
./scripts/generate_checksum.sh mypackage
325335
```
@@ -370,4 +380,4 @@ nutshell/
370380

371381
## License
372382

373-
[MIT License](LICENSE)
383+
[MIT License](LICENSE)

nutshell.rb

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,67 @@
1+
# frozen_string_literal: true
2+
13
class Nutshell < Formula
2-
desc "Enhanced Unix shell with simplified command language and AI assistance"
3-
homepage "https://github.com/chandralegend/nutshell"
4-
url "https://github.com/chandralegend/nutshell/archive/refs/tags/v0.0.4.tar.gz"
5-
sha256 "d3cd4b9b64fb6d657195beb7ea9d47a193ace561d8d54b64e9890304e41c6829"
6-
license "MIT"
7-
head "https://github.com/chandralegend/nutshell.git", branch: "main"
4+
desc 'Enhanced Unix shell with simplified command language and AI assistance'
5+
homepage 'https://github.com/chandralegend/nutshell'
6+
url 'https://github.com/chandralegend/nutshell/archive/refs/tags/v0.0.4.tar.gz'
7+
sha256 'd3cd4b9b64fb6d657195beb7ea9d47a193ace561d8d54b64e9890304e41c6829'
8+
license 'MIT'
9+
head 'https://github.com/chandralegend/nutshell.git', branch: 'main'
10+
11+
depends_on 'pkg-config' => :build
12+
depends_on 'jansson'
13+
depends_on 'readline'
14+
depends_on 'openssl@3'
15+
depends_on 'curl'
816

9-
depends_on "pkg-config" => :build
10-
depends_on "jansson"
11-
depends_on "readline"
12-
depends_on "openssl@3"
13-
depends_on "curl"
14-
1517
def install
1618
# Pass correct environment variables to find libraries
17-
ENV.append "CFLAGS", "-I#{Formula["jansson"].opt_include}"
18-
ENV.append "LDFLAGS", "-L#{Formula["jansson"].opt_lib} -ljansson"
19-
ENV.append "CFLAGS", "-I#{Formula["openssl@3"].opt_include}"
20-
ENV.append "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib}"
21-
22-
system "make"
23-
bin.install "nutshell"
24-
19+
ENV.append 'CFLAGS', "-I#{Formula['jansson'].opt_include}"
20+
ENV.append 'LDFLAGS', "-L#{Formula['jansson'].opt_lib} -ljansson"
21+
ENV.append 'CFLAGS', "-I#{Formula['openssl@3'].opt_include}"
22+
ENV.append 'LDFLAGS', "-L#{Formula['openssl@3'].opt_lib}"
23+
24+
system 'make'
25+
bin.install 'nutshell'
26+
2527
# Install documentation
26-
doc.install "README.md", "CHANGELOG.md"
27-
28+
doc.install 'README.md', 'CHANGELOG.md'
29+
2830
# Create themes directory and install themes directly in the Cellar
2931
# The themes directory will be in the Formula's prefix, not in /usr/local/share
30-
themes_dir = prefix/"themes"
32+
themes_dir = prefix / 'themes'
3133
themes_dir.mkpath
32-
Dir["themes/*.json"].each do |theme_file|
34+
Dir['themes/*.json'].each do |theme_file|
3335
themes_dir.install theme_file
3436
end
35-
37+
3638
# Create a nutshell config directory in the Formula's prefix for packages
37-
(prefix/"packages").mkpath
39+
(prefix / 'packages').mkpath
3840
end
3941

4042
def post_install
4143
# Create ~/.nutshell directory structure for the user if it doesn't exist
4244
user_config_dir = "#{Dir.home}/.nutshell"
4345
user_themes_dir = "#{user_config_dir}/themes"
4446
user_packages_dir = "#{user_config_dir}/packages"
45-
46-
system "mkdir", "-p", user_themes_dir
47-
system "mkdir", "-p", user_packages_dir
48-
47+
48+
system 'mkdir', '-p', user_themes_dir
49+
system 'mkdir', '-p', user_packages_dir
50+
4951
# Copy themes to user directory if it doesn't already have them
5052
if Dir.exist?(user_themes_dir) && Dir.empty?(user_themes_dir)
5153
Dir["#{prefix}/themes/*.json"].each do |theme|
52-
system "cp", theme, user_themes_dir
54+
system 'cp', theme, user_themes_dir
5355
end
5456
end
55-
57+
5658
# Print instructions for the user
57-
ohai "Nutshell has been installed!"
58-
opoo "Make sure to set an API key for AI features with: set-api-key YOUR_API_KEY"
59+
ohai 'Nutshell has been installed!'
60+
opoo 'Make sure to set an API key for AI features with: set-api-key YOUR_API_KEY'
5961
end
6062

6163
test do
6264
# Test that nutshell runs without errors (--help should return 0)
63-
assert_match "Nutshell", shell_output("#{bin}/nutshell --help", 0)
65+
assert_match 'Nutshell', shell_output("#{bin}/nutshell --help", 0)
6466
end
6567
end

0 commit comments

Comments
 (0)