factorix 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +20 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +105 -0
  5. data/completion/_factorix.bash +202 -0
  6. data/completion/_factorix.fish +197 -0
  7. data/completion/_factorix.zsh +376 -0
  8. data/doc/factorix.1 +377 -0
  9. data/exe/factorix +20 -0
  10. data/lib/factorix/api/category.rb +69 -0
  11. data/lib/factorix/api/image.rb +35 -0
  12. data/lib/factorix/api/license.rb +71 -0
  13. data/lib/factorix/api/mod_download_api.rb +66 -0
  14. data/lib/factorix/api/mod_info.rb +166 -0
  15. data/lib/factorix/api/mod_management_api.rb +237 -0
  16. data/lib/factorix/api/mod_portal_api.rb +204 -0
  17. data/lib/factorix/api/release.rb +49 -0
  18. data/lib/factorix/api/tag.rb +95 -0
  19. data/lib/factorix/api.rb +7 -0
  20. data/lib/factorix/api_credential.rb +54 -0
  21. data/lib/factorix/application.rb +218 -0
  22. data/lib/factorix/cache/file_system.rb +307 -0
  23. data/lib/factorix/cli/commands/backup_support.rb +46 -0
  24. data/lib/factorix/cli/commands/base.rb +90 -0
  25. data/lib/factorix/cli/commands/cache/evict.rb +180 -0
  26. data/lib/factorix/cli/commands/cache/stat.rb +201 -0
  27. data/lib/factorix/cli/commands/command_wrapper.rb +71 -0
  28. data/lib/factorix/cli/commands/completion.rb +83 -0
  29. data/lib/factorix/cli/commands/confirmable.rb +53 -0
  30. data/lib/factorix/cli/commands/download_support.rb +123 -0
  31. data/lib/factorix/cli/commands/launch.rb +79 -0
  32. data/lib/factorix/cli/commands/man.rb +29 -0
  33. data/lib/factorix/cli/commands/mod/check.rb +99 -0
  34. data/lib/factorix/cli/commands/mod/disable.rb +188 -0
  35. data/lib/factorix/cli/commands/mod/download.rb +291 -0
  36. data/lib/factorix/cli/commands/mod/edit.rb +114 -0
  37. data/lib/factorix/cli/commands/mod/enable.rb +216 -0
  38. data/lib/factorix/cli/commands/mod/image/add.rb +47 -0
  39. data/lib/factorix/cli/commands/mod/image/edit.rb +41 -0
  40. data/lib/factorix/cli/commands/mod/image/list.rb +74 -0
  41. data/lib/factorix/cli/commands/mod/install.rb +443 -0
  42. data/lib/factorix/cli/commands/mod/list.rb +372 -0
  43. data/lib/factorix/cli/commands/mod/search.rb +134 -0
  44. data/lib/factorix/cli/commands/mod/settings/dump.rb +88 -0
  45. data/lib/factorix/cli/commands/mod/settings/restore.rb +101 -0
  46. data/lib/factorix/cli/commands/mod/show.rb +202 -0
  47. data/lib/factorix/cli/commands/mod/sync.rb +299 -0
  48. data/lib/factorix/cli/commands/mod/uninstall.rb +325 -0
  49. data/lib/factorix/cli/commands/mod/update.rb +222 -0
  50. data/lib/factorix/cli/commands/mod/upload.rb +90 -0
  51. data/lib/factorix/cli/commands/path.rb +79 -0
  52. data/lib/factorix/cli/commands/requires_game_stopped.rb +32 -0
  53. data/lib/factorix/cli/commands/version.rb +25 -0
  54. data/lib/factorix/cli.rb +42 -0
  55. data/lib/factorix/dependency/edge.rb +89 -0
  56. data/lib/factorix/dependency/entry.rb +124 -0
  57. data/lib/factorix/dependency/graph/builder.rb +108 -0
  58. data/lib/factorix/dependency/graph.rb +210 -0
  59. data/lib/factorix/dependency/list.rb +244 -0
  60. data/lib/factorix/dependency/mod_version_requirement.rb +73 -0
  61. data/lib/factorix/dependency/node.rb +60 -0
  62. data/lib/factorix/dependency/parser.rb +148 -0
  63. data/lib/factorix/dependency/validation_result.rb +138 -0
  64. data/lib/factorix/dependency/validator.rb +190 -0
  65. data/lib/factorix/errors.rb +112 -0
  66. data/lib/factorix/formatting.rb +56 -0
  67. data/lib/factorix/game_version.rb +98 -0
  68. data/lib/factorix/http/cache_decorator.rb +106 -0
  69. data/lib/factorix/http/cached_response.rb +37 -0
  70. data/lib/factorix/http/client.rb +187 -0
  71. data/lib/factorix/http/response.rb +31 -0
  72. data/lib/factorix/http/retry_decorator.rb +59 -0
  73. data/lib/factorix/http/retry_strategy.rb +80 -0
  74. data/lib/factorix/info_json.rb +90 -0
  75. data/lib/factorix/installed_mod.rb +239 -0
  76. data/lib/factorix/mod.rb +55 -0
  77. data/lib/factorix/mod_list.rb +174 -0
  78. data/lib/factorix/mod_settings.rb +278 -0
  79. data/lib/factorix/mod_state.rb +34 -0
  80. data/lib/factorix/mod_version.rb +99 -0
  81. data/lib/factorix/portal.rb +185 -0
  82. data/lib/factorix/progress/download_handler.rb +46 -0
  83. data/lib/factorix/progress/multi_presenter.rb +45 -0
  84. data/lib/factorix/progress/presenter.rb +67 -0
  85. data/lib/factorix/progress/presenter_adapter.rb +46 -0
  86. data/lib/factorix/progress/scan_handler.rb +33 -0
  87. data/lib/factorix/progress/upload_handler.rb +33 -0
  88. data/lib/factorix/runtime/base.rb +233 -0
  89. data/lib/factorix/runtime/linux.rb +32 -0
  90. data/lib/factorix/runtime/mac_os.rb +53 -0
  91. data/lib/factorix/runtime/user_configurable.rb +69 -0
  92. data/lib/factorix/runtime/windows.rb +85 -0
  93. data/lib/factorix/runtime/wsl.rb +118 -0
  94. data/lib/factorix/runtime.rb +32 -0
  95. data/lib/factorix/save_file.rb +178 -0
  96. data/lib/factorix/ser_des/deserializer.rb +198 -0
  97. data/lib/factorix/ser_des/serializer.rb +231 -0
  98. data/lib/factorix/ser_des/signed_integer.rb +63 -0
  99. data/lib/factorix/ser_des/unsigned_integer.rb +65 -0
  100. data/lib/factorix/service_credential.rb +127 -0
  101. data/lib/factorix/transfer/downloader.rb +162 -0
  102. data/lib/factorix/transfer/uploader.rb +232 -0
  103. data/lib/factorix/version.rb +6 -0
  104. data/lib/factorix.rb +38 -0
  105. data/sig/dry/auto_inject.rbs +15 -0
  106. data/sig/dry/cli.rbs +19 -0
  107. data/sig/dry/configurable.rbs +13 -0
  108. data/sig/dry/core/container.rbs +17 -0
  109. data/sig/dry/events/publisher.rbs +22 -0
  110. data/sig/dry/logger.rbs +16 -0
  111. data/sig/factorix/api/category.rbs +15 -0
  112. data/sig/factorix/api/image.rbs +15 -0
  113. data/sig/factorix/api/license.rbs +20 -0
  114. data/sig/factorix/api/mod_download_api.rbs +18 -0
  115. data/sig/factorix/api/mod_info.rbs +67 -0
  116. data/sig/factorix/api/mod_management_api.rbs +25 -0
  117. data/sig/factorix/api/mod_portal_api.rbs +31 -0
  118. data/sig/factorix/api/release.rbs +27 -0
  119. data/sig/factorix/api/tag.rbs +15 -0
  120. data/sig/factorix/api.rbs +8 -0
  121. data/sig/factorix/api_credential.rbs +17 -0
  122. data/sig/factorix/application.rbs +86 -0
  123. data/sig/factorix/cache/file_system.rbs +35 -0
  124. data/sig/factorix/cli/commands/base.rbs +13 -0
  125. data/sig/factorix/cli/commands/cache/evict.rbs +17 -0
  126. data/sig/factorix/cli/commands/cache/stat.rbs +17 -0
  127. data/sig/factorix/cli/commands/command_wrapper.rbs +13 -0
  128. data/sig/factorix/cli/commands/completion/zsh.rbs +15 -0
  129. data/sig/factorix/cli/commands/confirmable.rbs +12 -0
  130. data/sig/factorix/cli/commands/download_support.rbs +12 -0
  131. data/sig/factorix/cli/commands/launch.rbs +15 -0
  132. data/sig/factorix/cli/commands/mod/check.rbs +18 -0
  133. data/sig/factorix/cli/commands/mod/disable.rbs +20 -0
  134. data/sig/factorix/cli/commands/mod/download.rbs +18 -0
  135. data/sig/factorix/cli/commands/mod/edit.rbs +30 -0
  136. data/sig/factorix/cli/commands/mod/enable.rbs +20 -0
  137. data/sig/factorix/cli/commands/mod/image/add.rbs +19 -0
  138. data/sig/factorix/cli/commands/mod/image/edit.rbs +19 -0
  139. data/sig/factorix/cli/commands/mod/image/list.rbs +19 -0
  140. data/sig/factorix/cli/commands/mod/install.rbs +19 -0
  141. data/sig/factorix/cli/commands/mod/list.rbs +30 -0
  142. data/sig/factorix/cli/commands/mod/search.rbs +18 -0
  143. data/sig/factorix/cli/commands/mod/settings/dump.rbs +17 -0
  144. data/sig/factorix/cli/commands/mod/settings/restore.rbs +17 -0
  145. data/sig/factorix/cli/commands/mod/sync.rbs +19 -0
  146. data/sig/factorix/cli/commands/mod/uninstall.rbs +20 -0
  147. data/sig/factorix/cli/commands/mod/update.rbs +19 -0
  148. data/sig/factorix/cli/commands/mod/upload.rbs +24 -0
  149. data/sig/factorix/cli/commands/path.rbs +18 -0
  150. data/sig/factorix/cli/commands/requires_game_stopped.rbs +13 -0
  151. data/sig/factorix/cli/commands/version.rbs +13 -0
  152. data/sig/factorix/cli.rbs +11 -0
  153. data/sig/factorix/dependency/edge.rbs +32 -0
  154. data/sig/factorix/dependency/entry.rbs +30 -0
  155. data/sig/factorix/dependency/graph/builder.rbs +17 -0
  156. data/sig/factorix/dependency/graph.rbs +39 -0
  157. data/sig/factorix/dependency/list.rbs +69 -0
  158. data/sig/factorix/dependency/mod_version_requirement.rbs +18 -0
  159. data/sig/factorix/dependency/node.rbs +24 -0
  160. data/sig/factorix/dependency/parser.rbs +11 -0
  161. data/sig/factorix/dependency/validation_result.rbs +56 -0
  162. data/sig/factorix/dependency/validator.rbs +13 -0
  163. data/sig/factorix/errors.rbs +132 -0
  164. data/sig/factorix/formatting.rbs +8 -0
  165. data/sig/factorix/game_version.rbs +24 -0
  166. data/sig/factorix/http/cache_decorator.rbs +64 -0
  167. data/sig/factorix/http/client.rbs +55 -0
  168. data/sig/factorix/http/response.rbs +28 -0
  169. data/sig/factorix/http/retry_decorator.rbs +44 -0
  170. data/sig/factorix/http/retry_strategy.rbs +42 -0
  171. data/sig/factorix/info_json.rbs +19 -0
  172. data/sig/factorix/installed_mod.rbs +34 -0
  173. data/sig/factorix/mod.rbs +20 -0
  174. data/sig/factorix/mod_list.rbs +44 -0
  175. data/sig/factorix/mod_settings.rbs +47 -0
  176. data/sig/factorix/mod_state.rbs +18 -0
  177. data/sig/factorix/mod_version.rbs +23 -0
  178. data/sig/factorix/portal.rbs +37 -0
  179. data/sig/factorix/progress/download_handler.rbs +19 -0
  180. data/sig/factorix/progress/multi_presenter.rbs +15 -0
  181. data/sig/factorix/progress/presenter.rbs +17 -0
  182. data/sig/factorix/progress/presenter_adapter.rbs +17 -0
  183. data/sig/factorix/progress/scan_handler.rbs +16 -0
  184. data/sig/factorix/progress/upload_handler.rbs +17 -0
  185. data/sig/factorix/runtime/base.rbs +45 -0
  186. data/sig/factorix/runtime/linux.rbs +15 -0
  187. data/sig/factorix/runtime/mac_os.rbs +15 -0
  188. data/sig/factorix/runtime/user_configurable.rbs +13 -0
  189. data/sig/factorix/runtime/windows.rbs +23 -0
  190. data/sig/factorix/runtime/wsl.rbs +19 -0
  191. data/sig/factorix/runtime.rbs +9 -0
  192. data/sig/factorix/save_file.rbs +40 -0
  193. data/sig/factorix/ser_des/deserializer.rbs +49 -0
  194. data/sig/factorix/ser_des/serializer.rbs +45 -0
  195. data/sig/factorix/ser_des/signed_integer.rbs +37 -0
  196. data/sig/factorix/ser_des/unsigned_integer.rbs +37 -0
  197. data/sig/factorix/service_credential.rbs +19 -0
  198. data/sig/factorix/transfer/downloader.rbs +15 -0
  199. data/sig/factorix/transfer/uploader.rbs +21 -0
  200. data/sig/factorix.rbs +9 -0
  201. data/sig/tty/progressbar.rbs +18 -0
  202. metadata +431 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 266f397cb572fd4db54fe30671c9ba4e8ba3f60a4b17593193a829ae69b526c0
4
+ data.tar.gz: aeecbbf8447e8823d2d374ad13899581f51060eda1ec95959f672b883e60c8a4
5
+ SHA512:
6
+ metadata.gz: 2c28e713c148c4ebb43f03094713c9b02a8c038dd64a8d6da6d69c5a09f43f1dcee7430e67a9b92be5d784d26f3986c25bf7e9d9cfd5ba3402469b0d0649723b
7
+ data.tar.gz: cec4b9103df79b6f2e94bb15599d4306346378030a18a3ea9480c27a7cf6004a62f7c2d2d6fa7c3c0d7416af0e4ebd5adeee5df2d281b2d68d09f9ce5d52c675
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.5.0] - 2025-12-26
4
+
5
+ ### Added
6
+
7
+ - **CLI tool** for Factorio MOD management, settings sync, and game control
8
+ - **MOD management commands**: installation, lifecycle, dependency validation
9
+ - **MOD Portal integration**: download, upload, metadata/image management
10
+ - **Utility commands**: version display, path info, game launch, shell completion
11
+ - **Cache management**: statistics and eviction
12
+ - **Dependency resolution** with graph-based analysis and incompatibility detection
13
+ - **Settings management**: export/import mod-settings.dat as JSON
14
+ - **Save file analysis**: extract MOD information and startup settings
15
+ - **Multi-platform support**: Linux (native and WSL), macOS, and Windows
16
+
17
+ For detailed documentation, see:
18
+ - [Project Overview](doc/overview.md)
19
+ - [CLI Commands](doc/components/cli.md)
20
+ - [Architecture](doc/architecture.md)
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 OZAWA Sakuro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # :gear: Factorix
2
+
3
+ A Ruby gem providing a CLI for Factorio MOD management, settings synchronization, and game control.
4
+
5
+ ## Overview
6
+
7
+ Factorix simplifies Factorio MOD management by providing:
8
+ - A CLI tool for everyday MOD operations
9
+ - Automatic dependency resolution and validation
10
+ - JSON-based MOD settings export/import
11
+ - Save file synchronization capabilities
12
+
13
+ ## Features
14
+
15
+ - **MOD Discovery & Download**: Search and download MODs from the Factorio MOD Portal
16
+ - **Dependency Management**: Automatic dependency resolution and validation with graph-based analysis
17
+ - **MOD State Management**: Enable/disable MODs with automatic handling of dependencies and dependents
18
+ - **Installation & Uninstallation**: Install MODs directly from the portal or uninstall existing MODs
19
+ - **Save File Sync**: Synchronize MOD states and startup settings from Factorio save files
20
+ - **Settings Management**: Export/import MOD settings in JSON format
21
+ - **MOD Portal Integration**: Upload new MODs or update existing ones, edit metadata
22
+ - **Game Control**: Launch Factorio from the command line
23
+ - **Cross-platform Support**: Works on Windows, Linux, macOS, and WSL
24
+
25
+ ## Requirements
26
+
27
+ - Ruby (non-EOL versions)
28
+ - Factorio API Key (required for uploading MODs and editing MOD metadata)
29
+ - Obtain your API key from [Factorio Profile](https://factorio.com/profile)
30
+
31
+ ## Setup
32
+
33
+ For uploading MODs or editing MOD metadata, set the `FACTORIO_API_KEY` environment variable:
34
+
35
+ ```bash
36
+ export FACTORIO_API_KEY=your_api_key_here
37
+ ```
38
+
39
+ API key is not required for downloading, installing, or managing local MODs.
40
+
41
+ ## Configuration
42
+
43
+ ### Path Configuration
44
+
45
+ Factorix auto-detects Factorio installation paths for Steam installations. For other environments or to override the detected paths, create a configuration file.
46
+
47
+ **Find configuration file location:**
48
+ ```bash
49
+ factorix path --json | jq -r .factorix_config_path
50
+ ```
51
+
52
+ **Create configuration file:**
53
+ ```bash
54
+ # Copy example configuration
55
+ cp example/config.rb ~/.config/factorix/config.rb
56
+
57
+ # Edit the configuration
58
+ $EDITOR ~/.config/factorix/config.rb
59
+ ```
60
+
61
+ **Configurable paths:**
62
+ - `executable_path` - Path to Factorio executable
63
+ - `user_dir` - Path to Factorio user directory (MODs, saves, settings)
64
+ - `data_dir` - Path to Factorio data directory
65
+
66
+ **Example configuration:**
67
+ ```ruby
68
+ Factorix::Application.configure do |config|
69
+ config.runtime.executable_path = "/Applications/Factorio.app/Contents/MacOS/factorio"
70
+ config.runtime.user_dir = "#{Dir.home}/Library/Application Support/factorio"
71
+ config.runtime.data_dir = "/Applications/Factorio.app/Contents/data"
72
+ end
73
+ ```
74
+
75
+ See [`example/config.rb`](example/config.rb) for platform-specific examples and additional configuration options.
76
+
77
+ **Alternative configuration path:**
78
+
79
+ You can specify a custom configuration file path using the `--config-path` option or `FACTORIX_CONFIG` environment variable:
80
+ ```bash
81
+ # Using CLI option
82
+ factorix mod list --config-path=/path/to/config.rb
83
+
84
+ # Using environment variable
85
+ export FACTORIX_CONFIG=/path/to/config.rb
86
+ factorix mod list
87
+ ```
88
+
89
+ ## Usage
90
+
91
+ Run `factorix --help` to see available commands, or `factorix <command> --help` for command-specific usage and examples.
92
+
93
+ For detailed CLI documentation, run `factorix man` or see [`doc/components/cli.md`](doc/components/cli.md).
94
+
95
+ ## Contributing
96
+
97
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sakuro/factorix.
98
+
99
+ For development setup and detailed contribution guidelines, please see [`DEVELOPMENT.md`](DEVELOPMENT.md).
100
+
101
+ ## License
102
+
103
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
104
+
105
+ Copyright (c) 2025 OZAWA Sakuro
@@ -0,0 +1,202 @@
1
+ # Bash completion for factorix
2
+ # Output by: factorix completion bash
3
+
4
+ # Helper function to get installed MOD names
5
+ _factorix_installed_mods() {
6
+ factorix mod list --json 2>/dev/null | jq -r '.[].name' 2>/dev/null
7
+ }
8
+
9
+ _factorix() {
10
+ local cur prev
11
+ cur="${COMP_WORDS[COMP_CWORD]}"
12
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
13
+ local cword=$COMP_CWORD
14
+ local words=("${COMP_WORDS[@]}")
15
+
16
+ local global_opts="-c --config-path --log-level -q --quiet"
17
+ local confirmable_opts="-y --yes"
18
+
19
+ # Top-level commands
20
+ local commands="version man launch path mod cache completion"
21
+
22
+ # mod subcommands
23
+ local mod_commands="check list show enable disable install uninstall update download upload edit search sync image settings"
24
+
25
+ # cache subcommands
26
+ local cache_commands="stat evict"
27
+
28
+ # mod image subcommands
29
+ local image_commands="list add edit"
30
+
31
+ # mod settings subcommands
32
+ local settings_commands="dump restore"
33
+
34
+ case "${words[1]}" in
35
+ version|man)
36
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
37
+ return
38
+ ;;
39
+ launch)
40
+ COMPREPLY=($(compgen -W "$global_opts -w --wait" -- "$cur"))
41
+ return
42
+ ;;
43
+ path)
44
+ COMPREPLY=($(compgen -W "$global_opts --json" -- "$cur"))
45
+ return
46
+ ;;
47
+ completion)
48
+ if [[ $cword -eq 2 ]] && [[ "$cur" != -* ]]; then
49
+ COMPREPLY=($(compgen -W "zsh bash fish" -- "$cur"))
50
+ else
51
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
52
+ fi
53
+ return
54
+ ;;
55
+ cache)
56
+ if [[ $cword -eq 2 ]]; then
57
+ COMPREPLY=($(compgen -W "$cache_commands" -- "$cur"))
58
+ else
59
+ case "${words[2]}" in
60
+ stat)
61
+ COMPREPLY=($(compgen -W "$global_opts --json" -- "$cur"))
62
+ ;;
63
+ evict)
64
+ if [[ "$cur" == -* ]]; then
65
+ COMPREPLY=($(compgen -W "$global_opts --all --expired --older-than" -- "$cur"))
66
+ else
67
+ COMPREPLY=($(compgen -W "download api info_json" -- "$cur"))
68
+ fi
69
+ ;;
70
+ *)
71
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
72
+ ;;
73
+ esac
74
+ fi
75
+ return
76
+ ;;
77
+ mod)
78
+ if [[ $cword -eq 2 ]]; then
79
+ COMPREPLY=($(compgen -W "$mod_commands" -- "$cur"))
80
+ else
81
+ case "${words[2]}" in
82
+ check)
83
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
84
+ ;;
85
+ list)
86
+ COMPREPLY=($(compgen -W "$global_opts --enabled --disabled --errors --outdated --json" -- "$cur"))
87
+ ;;
88
+ show)
89
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
90
+ ;;
91
+ enable|disable)
92
+ if [[ "$cur" == -* ]]; then
93
+ COMPREPLY=($(compgen -W "$global_opts $confirmable_opts" -- "$cur"))
94
+ else
95
+ local mods=$(_factorix_installed_mods)
96
+ COMPREPLY=($(compgen -W "$mods" -- "$cur"))
97
+ fi
98
+ ;;
99
+ install)
100
+ COMPREPLY=($(compgen -W "$global_opts $confirmable_opts -j --jobs" -- "$cur"))
101
+ ;;
102
+ uninstall)
103
+ if [[ "$cur" == -* ]]; then
104
+ COMPREPLY=($(compgen -W "$global_opts $confirmable_opts --all" -- "$cur"))
105
+ else
106
+ local mods=$(_factorix_installed_mods)
107
+ COMPREPLY=($(compgen -W "$mods" -- "$cur"))
108
+ fi
109
+ ;;
110
+ update)
111
+ if [[ "$cur" == -* ]]; then
112
+ COMPREPLY=($(compgen -W "$global_opts $confirmable_opts -j --jobs" -- "$cur"))
113
+ else
114
+ local mods=$(_factorix_installed_mods)
115
+ COMPREPLY=($(compgen -W "$mods" -- "$cur"))
116
+ fi
117
+ ;;
118
+ download)
119
+ COMPREPLY=($(compgen -W "$global_opts -d --directory -j --jobs -r --recursive" -- "$cur"))
120
+ ;;
121
+ upload)
122
+ if [[ "$cur" == -* ]]; then
123
+ COMPREPLY=($(compgen -W "$global_opts --description --category --license --source-url" -- "$cur"))
124
+ elif [[ "$prev" == "--category" ]]; then
125
+ COMPREPLY=($(compgen -W "content overhaul tweaks utilities scenarios mod-packs localizations internal no-category" -- "$cur"))
126
+ elif [[ "$prev" == "--license" ]]; then
127
+ COMPREPLY=($(compgen -W "default_mit default_gnugplv3 default_gnulgplv3 default_mozilla2 default_apache2 default_unlicense" -- "$cur"))
128
+ else
129
+ COMPREPLY=($(compgen -f -X '!*.zip' -- "$cur"))
130
+ fi
131
+ ;;
132
+ edit)
133
+ if [[ "$cur" == -* ]]; then
134
+ COMPREPLY=($(compgen -W "$global_opts --description --summary --title --category --tags --license --homepage --source-url --faq --deprecated --no-deprecated" -- "$cur"))
135
+ elif [[ "$prev" == "--category" ]]; then
136
+ COMPREPLY=($(compgen -W "content overhaul tweaks utilities scenarios mod-packs localizations internal no-category" -- "$cur"))
137
+ elif [[ "$prev" == "--license" ]]; then
138
+ COMPREPLY=($(compgen -W "default_mit default_gnugplv3 default_gnulgplv3 default_mozilla2 default_apache2 default_unlicense" -- "$cur"))
139
+ elif [[ "$prev" == "--tags" ]]; then
140
+ COMPREPLY=($(compgen -W "transportation logistics trains combat armor enemies character environment planets mining fluids logistic-network circuit-network manufacturing power storage blueprints cheats" -- "$cur"))
141
+ fi
142
+ ;;
143
+ search)
144
+ if [[ "$cur" == -* ]]; then
145
+ COMPREPLY=($(compgen -W "$global_opts --hide-deprecated --no-hide-deprecated --page --page-size --sort --sort-order --version --json" -- "$cur"))
146
+ elif [[ "$prev" == "--sort" ]]; then
147
+ COMPREPLY=($(compgen -W "name created_at updated_at" -- "$cur"))
148
+ elif [[ "$prev" == "--sort-order" ]]; then
149
+ COMPREPLY=($(compgen -W "asc desc" -- "$cur"))
150
+ fi
151
+ ;;
152
+ sync)
153
+ if [[ "$cur" == -* ]]; then
154
+ COMPREPLY=($(compgen -W "$global_opts $confirmable_opts -j --jobs" -- "$cur"))
155
+ else
156
+ COMPREPLY=($(compgen -f -X '!*.zip' -- "$cur"))
157
+ fi
158
+ ;;
159
+ image)
160
+ if [[ $cword -eq 3 ]]; then
161
+ COMPREPLY=($(compgen -W "$image_commands" -- "$cur"))
162
+ else
163
+ case "${words[3]}" in
164
+ add)
165
+ if [[ "$cur" == -* ]]; then
166
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
167
+ elif [[ $cword -eq 5 ]]; then
168
+ COMPREPLY=($(compgen -f -X '!*.@(png|jpg|jpeg|gif)' -- "$cur"))
169
+ fi
170
+ ;;
171
+ *)
172
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
173
+ ;;
174
+ esac
175
+ fi
176
+ ;;
177
+ settings)
178
+ if [[ $cword -eq 3 ]]; then
179
+ COMPREPLY=($(compgen -W "$settings_commands" -- "$cur"))
180
+ else
181
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
182
+ fi
183
+ ;;
184
+ *)
185
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
186
+ ;;
187
+ esac
188
+ fi
189
+ return
190
+ ;;
191
+ esac
192
+
193
+ # Top-level completion
194
+ if [[ $cword -eq 1 ]]; then
195
+ COMPREPLY=($(compgen -W "$commands" -- "$cur"))
196
+ else
197
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
198
+ fi
199
+ }
200
+
201
+ # Register the completion function
202
+ complete -F _factorix factorix
@@ -0,0 +1,197 @@
1
+ # Fish completion for factorix
2
+ # Output by: factorix completion fish
3
+
4
+ # Helper function to get installed MOD names
5
+ function __factorix_installed_mods
6
+ factorix mod list --json 2>/dev/null | jq -r '.[].name' 2>/dev/null
7
+ end
8
+
9
+ # Helper function to check if we're completing a specific subcommand
10
+ function __factorix_using_command
11
+ set -l cmd (commandline -opc)
12
+ set -l argc (count $cmd)
13
+
14
+ if test $argc -eq 1
15
+ return 1
16
+ end
17
+
18
+ for i in (seq 2 $argc)
19
+ switch $cmd[$i]
20
+ case '-*'
21
+ continue
22
+ case '*'
23
+ if test "$cmd[$i]" = "$argv[1]"
24
+ return 0
25
+ end
26
+ return 1
27
+ end
28
+ end
29
+ return 1
30
+ end
31
+
32
+ # Helper function to check nested subcommand
33
+ function __factorix_using_subcommand
34
+ set -l cmd (commandline -opc)
35
+ set -l argc (count $cmd)
36
+
37
+ if test $argc -lt 3
38
+ return 1
39
+ end
40
+
41
+ set -l parent $argv[1]
42
+ set -l sub $argv[2]
43
+
44
+ set -l found_parent 0
45
+ for i in (seq 2 $argc)
46
+ switch $cmd[$i]
47
+ case '-*'
48
+ continue
49
+ case '*'
50
+ if test $found_parent -eq 0
51
+ if test "$cmd[$i]" = "$parent"
52
+ set found_parent 1
53
+ else
54
+ return 1
55
+ end
56
+ else
57
+ if test "$cmd[$i]" = "$sub"
58
+ return 0
59
+ end
60
+ return 1
61
+ end
62
+ end
63
+ end
64
+ return 1
65
+ end
66
+
67
+ # Disable file completion by default
68
+ complete -c factorix -f
69
+
70
+ # Global options
71
+ complete -c factorix -s c -l config-path -d 'Path to configuration file' -r
72
+ complete -c factorix -l log-level -d 'Set log level' -xa 'debug info warn error fatal'
73
+ complete -c factorix -s q -l quiet -d 'Suppress non-essential output'
74
+
75
+ # Top-level commands
76
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a version -d 'Display Factorix version'
77
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a man -d 'Display the Factorix manual page'
78
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a launch -d 'Launch Factorio game'
79
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a path -d 'Display Factorio and Factorix paths'
80
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a mod -d 'MOD management commands'
81
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a cache -d 'Cache management commands'
82
+ complete -c factorix -n "not __factorix_using_command version; and not __factorix_using_command man; and not __factorix_using_command launch; and not __factorix_using_command path; and not __factorix_using_command mod; and not __factorix_using_command cache; and not __factorix_using_command completion" -a completion -d 'Generate shell completion script'
83
+
84
+ # launch options
85
+ complete -c factorix -n "__factorix_using_command launch" -s w -l wait -d 'Wait for the game to finish'
86
+
87
+ # path options
88
+ complete -c factorix -n "__factorix_using_command path" -l json -d 'Output in JSON format'
89
+
90
+ # completion shell argument
91
+ complete -c factorix -n "__factorix_using_command completion" -a 'zsh bash fish' -d 'Shell type'
92
+
93
+ # cache subcommands
94
+ complete -c factorix -n "__factorix_using_command cache" -a stat -d 'Display cache statistics'
95
+ complete -c factorix -n "__factorix_using_command cache" -a evict -d 'Evict cache entries'
96
+
97
+ # cache stat options
98
+ complete -c factorix -n "__factorix_using_subcommand cache stat" -l json -d 'Output in JSON format'
99
+
100
+ # cache evict options
101
+ complete -c factorix -n "__factorix_using_subcommand cache evict" -l all -d 'Remove all entries'
102
+ complete -c factorix -n "__factorix_using_subcommand cache evict" -l expired -d 'Remove expired entries only'
103
+ complete -c factorix -n "__factorix_using_subcommand cache evict" -l older-than -d 'Remove entries older than AGE' -r
104
+ complete -c factorix -n "__factorix_using_subcommand cache evict" -a 'download api info_json' -d 'Cache name'
105
+
106
+ # mod subcommands
107
+ complete -c factorix -n "__factorix_using_command mod" -a check -d 'Check MOD dependencies'
108
+ complete -c factorix -n "__factorix_using_command mod" -a list -d 'List installed MODs'
109
+ complete -c factorix -n "__factorix_using_command mod" -a show -d 'Show MOD details from Factorio MOD Portal'
110
+ complete -c factorix -n "__factorix_using_command mod" -a enable -d 'Enable MODs'
111
+ complete -c factorix -n "__factorix_using_command mod" -a disable -d 'Disable MODs'
112
+ complete -c factorix -n "__factorix_using_command mod" -a install -d 'Install MODs from Factorio MOD Portal'
113
+ complete -c factorix -n "__factorix_using_command mod" -a uninstall -d 'Uninstall MODs'
114
+ complete -c factorix -n "__factorix_using_command mod" -a update -d 'Update MODs'
115
+ complete -c factorix -n "__factorix_using_command mod" -a download -d 'Download MODs without installing'
116
+ complete -c factorix -n "__factorix_using_command mod" -a upload -d 'Upload MOD to Factorio MOD Portal'
117
+ complete -c factorix -n "__factorix_using_command mod" -a edit -d 'Edit MOD metadata on Factorio MOD Portal'
118
+ complete -c factorix -n "__factorix_using_command mod" -a search -d 'Search MODs on Factorio MOD Portal'
119
+ complete -c factorix -n "__factorix_using_command mod" -a sync -d 'Sync MOD states from a save file'
120
+ complete -c factorix -n "__factorix_using_command mod" -a image -d 'MOD image management'
121
+ complete -c factorix -n "__factorix_using_command mod" -a settings -d 'MOD settings management'
122
+
123
+ # mod list options
124
+ complete -c factorix -n "__factorix_using_subcommand mod list" -l enabled -d 'Show only enabled MODs'
125
+ complete -c factorix -n "__factorix_using_subcommand mod list" -l disabled -d 'Show only disabled MODs'
126
+ complete -c factorix -n "__factorix_using_subcommand mod list" -l errors -d 'Show only MODs with dependency errors'
127
+ complete -c factorix -n "__factorix_using_subcommand mod list" -l outdated -d 'Show only MODs with available updates'
128
+ complete -c factorix -n "__factorix_using_subcommand mod list" -l json -d 'Output in JSON format'
129
+
130
+ # mod enable/disable options
131
+ complete -c factorix -n "__factorix_using_subcommand mod enable" -s y -l yes -d 'Skip confirmation prompts'
132
+ complete -c factorix -n "__factorix_using_subcommand mod enable" -a '(__factorix_installed_mods)' -d 'MOD name'
133
+ complete -c factorix -n "__factorix_using_subcommand mod disable" -s y -l yes -d 'Skip confirmation prompts'
134
+ complete -c factorix -n "__factorix_using_subcommand mod disable" -a '(__factorix_installed_mods)' -d 'MOD name'
135
+
136
+ # mod install options
137
+ complete -c factorix -n "__factorix_using_subcommand mod install" -s y -l yes -d 'Skip confirmation prompts'
138
+ complete -c factorix -n "__factorix_using_subcommand mod install" -s j -l jobs -d 'Number of parallel downloads' -r
139
+
140
+ # mod uninstall options
141
+ complete -c factorix -n "__factorix_using_subcommand mod uninstall" -s y -l yes -d 'Skip confirmation prompts'
142
+ complete -c factorix -n "__factorix_using_subcommand mod uninstall" -l all -d 'Uninstall all MODs'
143
+ complete -c factorix -n "__factorix_using_subcommand mod uninstall" -a '(__factorix_installed_mods)' -d 'MOD name'
144
+
145
+ # mod update options
146
+ complete -c factorix -n "__factorix_using_subcommand mod update" -s y -l yes -d 'Skip confirmation prompts'
147
+ complete -c factorix -n "__factorix_using_subcommand mod update" -s j -l jobs -d 'Number of parallel downloads' -r
148
+ complete -c factorix -n "__factorix_using_subcommand mod update" -a '(__factorix_installed_mods)' -d 'MOD name'
149
+
150
+ # mod download options
151
+ complete -c factorix -n "__factorix_using_subcommand mod download" -s d -l directory -d 'Download directory' -ra '(__fish_complete_directories)'
152
+ complete -c factorix -n "__factorix_using_subcommand mod download" -s j -l jobs -d 'Number of parallel downloads' -r
153
+ complete -c factorix -n "__factorix_using_subcommand mod download" -s r -l recursive -d 'Include required dependencies recursively'
154
+
155
+ # mod upload options
156
+ complete -c factorix -n "__factorix_using_subcommand mod upload" -l description -d 'Markdown description' -r
157
+ complete -c factorix -n "__factorix_using_subcommand mod upload" -l category -d 'MOD category' -xa 'content overhaul tweaks utilities scenarios mod-packs localizations internal no-category'
158
+ complete -c factorix -n "__factorix_using_subcommand mod upload" -l license -d 'License identifier' -xa 'default_mit default_gnugplv3 default_gnulgplv3 default_mozilla2 default_apache2 default_unlicense'
159
+ complete -c factorix -n "__factorix_using_subcommand mod upload" -l source-url -d 'Repository URL' -r
160
+ complete -c factorix -n "__factorix_using_subcommand mod upload" -ra '(__fish_complete_suffix .zip)'
161
+
162
+ # mod edit options
163
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l description -d 'Markdown description' -r
164
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l summary -d 'Brief description' -r
165
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l title -d 'MOD title' -r
166
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l category -d 'MOD category' -xa 'content overhaul tweaks utilities scenarios mod-packs localizations internal no-category'
167
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l tags -d 'Tags' -xa 'transportation logistics trains combat armor enemies character environment planets mining fluids logistic-network circuit-network manufacturing power storage blueprints cheats'
168
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l license -d 'License identifier' -xa 'default_mit default_gnugplv3 default_gnulgplv3 default_mozilla2 default_apache2 default_unlicense'
169
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l homepage -d 'Homepage URL' -r
170
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l source-url -d 'Repository URL' -r
171
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l faq -d 'FAQ text' -r
172
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l deprecated -d 'Deprecation flag'
173
+ complete -c factorix -n "__factorix_using_subcommand mod edit" -l no-deprecated -d 'Clear deprecation flag'
174
+
175
+ # mod search options
176
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l hide-deprecated -d 'Hide deprecated MODs'
177
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l no-hide-deprecated -d 'Show deprecated MODs'
178
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l page -d 'Page number' -r
179
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l page-size -d 'Results per page' -r
180
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l sort -d 'Sort field' -xa 'name created_at updated_at'
181
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l sort-order -d 'Sort order' -xa 'asc desc'
182
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l version -d 'Filter by Factorio version' -r
183
+ complete -c factorix -n "__factorix_using_subcommand mod search" -l json -d 'Output in JSON format'
184
+
185
+ # mod sync options
186
+ complete -c factorix -n "__factorix_using_subcommand mod sync" -s y -l yes -d 'Skip confirmation prompts'
187
+ complete -c factorix -n "__factorix_using_subcommand mod sync" -s j -l jobs -d 'Number of parallel downloads' -r
188
+ complete -c factorix -n "__factorix_using_subcommand mod sync" -ra '(__fish_complete_suffix .zip)'
189
+
190
+ # mod image subcommands
191
+ complete -c factorix -n "__factorix_using_subcommand mod image" -a list -d 'List MOD images'
192
+ complete -c factorix -n "__factorix_using_subcommand mod image" -a add -d 'Add an image to a MOD'
193
+ complete -c factorix -n "__factorix_using_subcommand mod image" -a edit -d 'Edit MOD images'
194
+
195
+ # mod settings subcommands
196
+ complete -c factorix -n "__factorix_using_subcommand mod settings" -a dump -d 'Dump MOD settings to JSON'
197
+ complete -c factorix -n "__factorix_using_subcommand mod settings" -a restore -d 'Restore MOD settings from JSON'