| 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.1.0.tar.gz" |
| 5 | sha256 "e38b495296e87f7bee7140ed662a37ee23f2f428e459b9c455f846f856014d4e" |
| 6 | license "MIT" |
| 7 | |
| 8 | depends_on "fpm" => :build |
| 9 | depends_on "gcc" # for gfortran |
| 10 | |
| 11 | def install |
| 12 | # Build the binary |
| 13 | system "fpm", "build", "--flag", "-O2" |
| 14 | |
| 15 | # Find the built binary (the gfortran_* directory name varies) |
| 16 | built_binary = Dir["build/gfortran_*/app/fortress"].first |
| 17 | raise "Could not find built binary" unless built_binary |
| 18 | |
| 19 | # Install the binary |
| 20 | bin.install built_binary => "fortress-bin" |
| 21 | |
| 22 | # Install shell integration files |
| 23 | (share/"fortress").install "fortress.sh" |
| 24 | (share/"fortress").install "fortress.fish" |
| 25 | |
| 26 | # Install documentation |
| 27 | doc.install "README.md" |
| 28 | doc.install "USAGE.md" if File.exist?("USAGE.md") |
| 29 | end |
| 30 | |
| 31 | def caveats |
| 32 | <<~EOS |
| 33 | FORTRESS has been installed! |
| 34 | |
| 35 | The binary is installed as 'fortress-bin', but you'll want to use |
| 36 | the shell wrapper function for the cd-on-exit feature. |
| 37 | |
| 38 | === Bash/Zsh Setup === |
| 39 | Add to your ~/.bashrc or ~/.zshrc: |
| 40 | source #{HOMEBREW_PREFIX}/share/fortress/fortress.sh |
| 41 | |
| 42 | Then restart your shell or run: |
| 43 | source ~/.bashrc # or ~/.zshrc |
| 44 | |
| 45 | === Fish Setup === |
| 46 | Add to your ~/.config/fish/config.fish: |
| 47 | source #{HOMEBREW_PREFIX}/share/fortress/fortress.fish |
| 48 | |
| 49 | Then restart your shell or run: |
| 50 | source ~/.config/fish/config.fish |
| 51 | |
| 52 | === Usage === |
| 53 | After setup, just run: |
| 54 | fortress |
| 55 | |
| 56 | Press 'c' on any directory to cd there and exit. |
| 57 | |
| 58 | Documentation: #{HOMEBREW_PREFIX}/share/doc/fortress/ |
| 59 | EOS |
| 60 | end |
| 61 | |
| 62 | test do |
| 63 | # Test that the binary exists and runs |
| 64 | assert_predicate bin/"fortress-bin", :exist? |
| 65 | assert_predicate bin/"fortress-bin", :executable? |
| 66 | |
| 67 | # Test that shell integration files exist |
| 68 | assert_predicate share/"fortress/fortress.sh", :exist? |
| 69 | assert_predicate share/"fortress/fortress.fish", :exist? |
| 70 | end |
| 71 | end |