|
| 1 | +# frozen_string_literal: true |
| 2 | + |
1 | 3 | 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' |
8 | 16 |
|
9 | | - depends_on "pkg-config" => :build |
10 | | - depends_on "jansson" |
11 | | - depends_on "readline" |
12 | | - depends_on "openssl@3" |
13 | | - depends_on "curl" |
14 | | - |
15 | 17 | def install |
16 | 18 | # 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 | + |
25 | 27 | # Install documentation |
26 | | - doc.install "README.md", "CHANGELOG.md" |
27 | | - |
| 28 | + doc.install 'README.md', 'CHANGELOG.md' |
| 29 | + |
28 | 30 | # Create themes directory and install themes directly in the Cellar |
29 | 31 | # 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' |
31 | 33 | themes_dir.mkpath |
32 | | - Dir["themes/*.json"].each do |theme_file| |
| 34 | + Dir['themes/*.json'].each do |theme_file| |
33 | 35 | themes_dir.install theme_file |
34 | 36 | end |
35 | | - |
| 37 | + |
36 | 38 | # Create a nutshell config directory in the Formula's prefix for packages |
37 | | - (prefix/"packages").mkpath |
| 39 | + (prefix / 'packages').mkpath |
38 | 40 | end |
39 | 41 |
|
40 | 42 | def post_install |
41 | 43 | # Create ~/.nutshell directory structure for the user if it doesn't exist |
42 | 44 | user_config_dir = "#{Dir.home}/.nutshell" |
43 | 45 | user_themes_dir = "#{user_config_dir}/themes" |
44 | 46 | 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 | + |
49 | 51 | # Copy themes to user directory if it doesn't already have them |
50 | 52 | if Dir.exist?(user_themes_dir) && Dir.empty?(user_themes_dir) |
51 | 53 | Dir["#{prefix}/themes/*.json"].each do |theme| |
52 | | - system "cp", theme, user_themes_dir |
| 54 | + system 'cp', theme, user_themes_dir |
53 | 55 | end |
54 | 56 | end |
55 | | - |
| 57 | + |
56 | 58 | # 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' |
59 | 61 | end |
60 | 62 |
|
61 | 63 | test do |
62 | 64 | # 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) |
64 | 66 | end |
65 | 67 | end |
0 commit comments