Skip to content

Commit f26698d

Browse files
committed
refactor: Add goversioninfo for generating version information in Windows executable
1 parent 0268ada commit f26698d

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

icon.ico

16.6 KB
Binary file not shown.

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// go: generate goversioninfo -icon = icon_piarchiver.ico
2+
13
package main
24

35
import (
@@ -25,6 +27,6 @@ func main() {
2527
utils.ColorPrint(utils.RED, err.Error() + "\n")
2628
os.Exit(1)
2729
}
28-
30+
2931
utils.ColorPrint(utils.GREEN, "Done\n")
3032
}

resources.rc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// resources.rc
2+
3+
IDI_ICON1 ICON "icon.ico"
4+
5+
1 VERSIONINFO
6+
FILEVERSION 0,0,2
7+
PRODUCTVERSION 0,0,2
8+
FILEOS 0x4
9+
FILETYPE 0x1
10+
{
11+
BLOCK "StringFileInfo"
12+
{
13+
BLOCK "040904b0"
14+
{
15+
VALUE "CompanyName", "BrainbirdLab"
16+
VALUE "FileDescription", "File Compress-Encryption program"
17+
VALUE "FileVersion", "0.0.2"
18+
VALUE "InternalName", "piarchiver"
19+
VALUE "LegalCopyright", "BrainbirdLab"
20+
VALUE "OriginalFilename", "piarchiver"
21+
VALUE "ProductName", "PiArchiver"
22+
VALUE "ProductVersion", "0.0.2"
23+
VALUE "Author", "Fuad Hasan"
24+
}
25+
}
26+
BLOCK "VarFileInfo"
27+
{
28+
VALUE "Translation", 0x409, 1200
29+
}
30+
}

resources.syso

17.7 KB
Binary file not shown.

utils/cli.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ import (
99

1010
func ParseCLI() ([]string, *string, *string, *bool) {
1111
//cli arguments
12+
13+
//if -v or --version is passed then skip the other flags
14+
version := flag.Bool("v", false, "Print version")
1215
inputFiles := flag.String("i", "", "Input files to be compressed")
1316
outputDir := flag.String("o", "", "Output directory for compressed files (Optional)")
1417
password := flag.String("p", "", "Password for encryption (Optional)")
1518
readAllFiles := flag.Bool("a", false, "Read all files in the test directory")
1619
decompressMode := flag.Bool("d", false, "Decompress mode")
1720
flag.Parse()
1821

22+
if *version {
23+
ColorPrint(WHITE, "---------- PI ARCHIVER ----------\n")
24+
ColorPrint(YELLOW, "Version: v0.0.2\n")
25+
//dev info
26+
ColorPrint(WHITE, "Developed by: https://github.com/itsfuad/\n")
27+
ColorPrint(WHITE, "---------------------------------")
28+
os.Exit(0)
29+
}
30+
1931
if *inputFiles == "" {
2032
ColorPrint(RED, "No input files provided\n")
2133
flag.Usage()

0 commit comments

Comments
 (0)