| 1 | class Fortress < Formula |
| 2 | desc "Command-line file explorer written in modern Fortran with cd-on-exit" |
| 3 | homepage "https://github.com/FortranGoingOnForty/fortress" |
| 4 | url "https://github.com/FortranGoingOnForty/fortress/archive/v0.9.99.tar.gz" |
| 5 | sha256 "5eb08ae980e3e4d3469510eda0c5d325db831ab8f3ac3146befd51efa929245f" |
| 6 | license "MIT" |
| 7 | |
| 8 | depends_on "fpm" => :build |
| 9 | depends_on "gcc" # for gfortran |
| 10 | depends_on "fzf" |
| 11 | depends_on "git" |
| 12 | |
| 13 | def install |
| 14 | # Build the binary |
| 15 | system "fpm", "build", "--flag", "-O2" |
| 16 | |
| 17 | # Find the built binary (the gfortran_* directory name varies) |
| 18 | built_binary = Dir["build/gfortran_*/app/fortress"].first |
| 19 | raise "Could not find built binary" unless built_binary |
| 20 | |
| 21 | # Install the actual binary |
| 22 | bin.install built_binary => "fortress-bin" |
| 23 | |
| 24 | # Create a simple wrapper script for basic usage |
| 25 | # Note: For cd-on-exit feature, users still need to source the shell integration |
| 26 | (bin/"fortress").write <<~EOS |
| 27 | #!/bin/bash |
| 28 | exec "#{bin}/fortress-bin" "$@" |
| 29 | EOS |
| 30 | |
| 31 | # Install shell integration files for cd-on-exit feature |
| 32 | (share/"fortress").install "fortress.sh" |
| 33 | (share/"fortress").install "fortress.fish" |
| 34 | |
| 35 | # Install documentation |
| 36 | doc.install "README.md" |
| 37 | doc.install "USAGE.md" if File.exist?("USAGE.md") |
| 38 | end |
| 39 | |
| 40 | def caveats |
| 41 | <<~EOS |
| 42 | FORTRESS has been installed! |
| 43 | |
| 44 | Basic usage: |
| 45 | fortress # Works immediately, all git features included |
| 46 | |
| 47 | === CD-ON-EXIT FEATURE (Optional) === |
| 48 | To enable the 'c' key to change your shell's directory: |
| 49 | |
| 50 | Bash/Zsh - Add to ~/.bashrc or ~/.zshrc: |
| 51 | source #{HOMEBREW_PREFIX}/share/fortress/fortress.sh |
| 52 | |
| 53 | Fish - Add to ~/.config/fish/config.fish: |
| 54 | source #{HOMEBREW_PREFIX}/share/fortress/fortress.fish |
| 55 | |
| 56 | Then restart your shell or source the config file. |
| 57 | |
| 58 | With shell integration, press 'c' on any directory to cd there and exit. |
| 59 | |
| 60 | Documentation: #{HOMEBREW_PREFIX}/share/doc/fortress/ |
| 61 | EOS |
| 62 | end |
| 63 | |
| 64 | test do |
| 65 | # Test that both binaries exist and are executable |
| 66 | assert_predicate bin/"fortress-bin", :exist? |
| 67 | assert_predicate bin/"fortress-bin", :executable? |
| 68 | assert_predicate bin/"fortress", :exist? |
| 69 | assert_predicate bin/"fortress", :executable? |
| 70 | |
| 71 | # Test that shell integration files exist |
| 72 | assert_predicate share/"fortress/fortress.sh", :exist? |
| 73 | assert_predicate share/"fortress/fortress.fish", :exist? |
| 74 | end |
| 75 | end |