fortrangoingonforty/fortress / 272a1cf

Browse files

stamp version onto binary, add --help, --version flags

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
272a1cf192e010751ae5186d9d53045ec8ae0731
Parents
f3b98e2
Tree
2149721

6 changed files

StatusFile+-
A VERSION 1 0
M app/main.f90 18 1
M fortress.spec 1 1
M fpm.toml 1 1
A src/version/version.f90 69 0
A stamp-version.sh 112 0
VERSIONadded
@@ -0,0 +1,1 @@
1
+1.0.1
app/main.f90modified
@@ -4,6 +4,7 @@ program fortress
44
     use filesystem_ops
55
     use git_ops
66
     use ui_display
7
+    use version_info
78
     implicit none
89
 
910
     ! State variables
@@ -67,7 +68,23 @@ program fortress
6768
     character(len=1) :: key
6869
     integer :: i, rows, cols, visible_height, top_padding
6970
     logical :: is_shift_pressed, is_alt_pressed
70
-    character(len=256) :: term_program
71
+    character(len=256) :: term_program, arg
72
+
73
+    ! Parse command-line arguments
74
+    if (command_argument_count() > 0) then
75
+        call get_command_argument(1, arg)
76
+        if (trim(arg) == '--help' .or. trim(arg) == '-h') then
77
+            call print_help()
78
+            stop
79
+        else if (trim(arg) == '--version' .or. trim(arg) == '-v') then
80
+            call print_version()
81
+            stop
82
+        else
83
+            print '(A)', 'Error: Unknown option: ' // trim(arg)
84
+            print '(A)', "Run 'fortress --help' for usage information"
85
+            stop 1
86
+        end if
87
+    end if
7188
 
7289
     ! Initialize
7390
     current_dir = get_pwd()
fortress.specmodified
@@ -1,7 +1,7 @@
11
 %global debug_package %{nil}
22
 
33
 Name:           fortress
4
-Version:        1.0.0
4
+Version:        1.0.1
55
 Release:        1%{?dist}
66
 Summary:        A command-line file explorer written in modern Fortran with cd-on-exit
77
 
fpm.tomlmodified
@@ -1,5 +1,5 @@
11
 name = "fortress"
2
-version = "0.1.0"
2
+version = "1.0.1"
33
 license = "MIT"
44
 author = "Matthew Wolffe"
55
 maintainer = "mfwolffe@outlook.com"
src/version/version.f90added
@@ -0,0 +1,69 @@
1
+! Auto-generated by stamp-version.sh - DO NOT EDIT MANUALLY
2
+module version_info
3
+    implicit none
4
+    private
5
+
6
+    public :: FORTRESS_VERSION, print_version, print_help
7
+
8
+    character(len=*), parameter :: FORTRESS_VERSION = '1.0.1'
9
+
10
+contains
11
+
12
+    subroutine print_version()
13
+        print '(A,A)', 'fortress v', FORTRESS_VERSION
14
+        print '(A)', ''
15
+        print '(A)', 'A command-line file explorer written in modern Fortran'
16
+        print '(A)', 'https://github.com/FortranGoingOnForty/fortress'
17
+    end subroutine print_version
18
+
19
+    subroutine print_help()
20
+        print '(A)', 'fortress - a dual-pane file explorer with fzf and git integration'
21
+        print '(A)', ''
22
+        print '(A)', 'USAGE:'
23
+        print '(A)', '  fortress [OPTIONS]'
24
+        print '(A)', ''
25
+        print '(A)', 'OPTIONS:'
26
+        print '(A)', '  -h, --help       Show this help message'
27
+        print '(A)', '  -v, --version    Show version information'
28
+        print '(A)', ''
29
+        print '(A)', 'NAVIGATION:'
30
+        print '(A)', '  up/down          Navigate up/down'
31
+        print '(A)', '  right            Enter directory'
32
+        print '(A)', '  left             Go to parent directory'
33
+        print '(A)', '  ~                Jump to home directory'
34
+        print '(A)', '  /                Jump to root directory'
35
+        print '(A)', '  8                Jump to favorites'
36
+        print '(A)', '  *                Toggle favorite'
37
+        print '(A)', '  .                Toggle hidden files'
38
+        print '(A)', '  [type chars]     Fuzzy jump to file'
39
+        print '(A)', ''
40
+        print '(A)', 'FILE OPERATIONS (Alt+key):'
41
+        print '(A)', '  Alt+n            Rename file/directory'
42
+        print '(A)', '  Alt+v            View/open file'
43
+        print '(A)', '  Alt+m            Move mode'
44
+        print '(A)', '  Alt+y            Yank (copy)'
45
+        print '(A)', '  Alt+x            Cut'
46
+        print '(A)', '  Alt+p            Paste'
47
+        print '(A)', '  Alt+r            Remove/delete'
48
+        print '(A)', '  Alt+s            Search with fzf'
49
+        print '(A)', '  Alt+c            CD on exit'
50
+        print '(A)', ''
51
+        print '(A)', 'SELECTION:'
52
+        print '(A)', '  Space            Toggle selection'
53
+        print '(A)', '  Shift+up/down    Block select'
54
+        print '(A)', '  e                Exit selection mode'
55
+        print '(A)', ''
56
+        print '(A)', 'GIT (Alt+g to toggle git mode):'
57
+        print '(A)', '  a                Stage file/directory'
58
+        print '(A)', '  u                Unstage'
59
+        print '(A)', '  m                Commit'
60
+        print '(A)', '  d                Show diff'
61
+        print '(A)', '  f                Fetch'
62
+        print '(A)', '  l                Pull'
63
+        print '(A)', '  h                Push'
64
+        print '(A)', '  t                Tag'
65
+        print '(A)', ''
66
+        print '(A)', 'Ctrl+q to quit'
67
+    end subroutine print_help
68
+
69
+end module version_info
stamp-version.shadded
@@ -0,0 +1,112 @@
1
+#!/bin/bash
2
+# stamp-version.sh - Stamp version from VERSION file into source and config files
3
+# Run this before building to ensure version consistency across all files
4
+
5
+set -e
6
+
7
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+cd "$SCRIPT_DIR"
9
+
10
+# Read version from VERSION file
11
+if [ ! -f VERSION ]; then
12
+    echo "Error: VERSION file not found" >&2
13
+    exit 1
14
+fi
15
+
16
+VERSION=$(cat VERSION | tr -d '[:space:]')
17
+
18
+if [ -z "$VERSION" ]; then
19
+    echo "Error: VERSION file is empty" >&2
20
+    exit 1
21
+fi
22
+
23
+echo "Stamping version: $VERSION"
24
+
25
+# Generate version module
26
+mkdir -p src/version
27
+cat > src/version/version.f90 << EOF
28
+! Auto-generated by stamp-version.sh - DO NOT EDIT MANUALLY
29
+module version_info
30
+    implicit none
31
+    private
32
+
33
+    public :: FORTRESS_VERSION, print_version, print_help
34
+
35
+    character(len=*), parameter :: FORTRESS_VERSION = '$VERSION'
36
+
37
+contains
38
+
39
+    subroutine print_version()
40
+        print '(A,A)', 'fortress v', FORTRESS_VERSION
41
+        print '(A)', ''
42
+        print '(A)', 'A command-line file explorer written in modern Fortran'
43
+        print '(A)', 'https://github.com/FortranGoingOnForty/fortress'
44
+    end subroutine print_version
45
+
46
+    subroutine print_help()
47
+        print '(A)', 'fortress - a dual-pane file explorer with fzf and git integration'
48
+        print '(A)', ''
49
+        print '(A)', 'USAGE:'
50
+        print '(A)', '  fortress [OPTIONS]'
51
+        print '(A)', ''
52
+        print '(A)', 'OPTIONS:'
53
+        print '(A)', '  -h, --help       Show this help message'
54
+        print '(A)', '  -v, --version    Show version information'
55
+        print '(A)', ''
56
+        print '(A)', 'NAVIGATION:'
57
+        print '(A)', '  up/down          Navigate up/down'
58
+        print '(A)', '  right            Enter directory'
59
+        print '(A)', '  left             Go to parent directory'
60
+        print '(A)', '  ~                Jump to home directory'
61
+        print '(A)', '  /                Jump to root directory'
62
+        print '(A)', '  8                Jump to favorites'
63
+        print '(A)', '  *                Toggle favorite'
64
+        print '(A)', '  .                Toggle hidden files'
65
+        print '(A)', '  [type chars]     Fuzzy jump to file'
66
+        print '(A)', ''
67
+        print '(A)', 'FILE OPERATIONS (Alt+key):'
68
+        print '(A)', '  Alt+n            Rename file/directory'
69
+        print '(A)', '  Alt+v            View/open file'
70
+        print '(A)', '  Alt+m            Move mode'
71
+        print '(A)', '  Alt+y            Yank (copy)'
72
+        print '(A)', '  Alt+x            Cut'
73
+        print '(A)', '  Alt+p            Paste'
74
+        print '(A)', '  Alt+r            Remove/delete'
75
+        print '(A)', '  Alt+s            Search with fzf'
76
+        print '(A)', '  Alt+c            CD on exit'
77
+        print '(A)', ''
78
+        print '(A)', 'SELECTION:'
79
+        print '(A)', '  Space            Toggle selection'
80
+        print '(A)', '  Shift+up/down    Block select'
81
+        print '(A)', '  e                Exit selection mode'
82
+        print '(A)', ''
83
+        print '(A)', 'GIT (Alt+g to toggle git mode):'
84
+        print '(A)', '  a                Stage file/directory'
85
+        print '(A)', '  u                Unstage'
86
+        print '(A)', '  m                Commit'
87
+        print '(A)', '  d                Show diff'
88
+        print '(A)', '  f                Fetch'
89
+        print '(A)', '  l                Pull'
90
+        print '(A)', '  h                Push'
91
+        print '(A)', '  t                Tag'
92
+        print '(A)', ''
93
+        print '(A)', 'Ctrl+q to quit'
94
+    end subroutine print_help
95
+
96
+end module version_info
97
+EOF
98
+echo "  -> src/version/version.f90"
99
+
100
+# Update fpm.toml
101
+if [ -f fpm.toml ]; then
102
+    sed -i "s/^version = .*/version = \"$VERSION\"/" fpm.toml
103
+    echo "  -> fpm.toml"
104
+fi
105
+
106
+# Update fortress.spec
107
+if [ -f fortress.spec ]; then
108
+    sed -i "s/^Version:.*/Version:        $VERSION/" fortress.spec
109
+    echo "  -> fortress.spec"
110
+fi
111
+
112
+echo "Done!"