Commit Graph

65 Commits

Author SHA1 Message Date
Tai Groot adf3c36632 fix(helpers): return ErrValueNotSet for nonexistent units in GetNumRestarts (#9)
systemd returns NRestarts=0 for units with LoadState=not-found, making
it indistinguishable from a genuinely loaded unit with zero restarts.
GetNumRestarts now checks LoadState when NRestarts is 0 and returns
ErrValueNotSet for units that don't exist, matching GetMemoryUsage
behavior.

Also adds unit tests for filterErr (all stderr error mapping cases)
and HasValidUnitSuffix (all valid unit types + negative cases).

Updates syncthing test expectation from ErrValueNotSet to nil since
loaded-but-inactive units legitimately have NRestarts=0.
2026-03-05 12:26:12 -05:00
Tai Groot 22132919e5 feat: add optional variadic args to all commands (#8)
Allow callers to pass additional systemctl flags (e.g. --no-block,
--force) via variadic string args on every exported function.

This is backward-compatible: existing callers without extra args
continue to work unchanged.

Introduces a prepareArgs helper to centralize argument construction,
replacing the duplicated args/UserMode pattern across all functions.

Closes #2
2026-02-26 11:03:53 -05:00
Tai Groot d38136c0dc refactor: clean up unused code, fix typos, improve docs (#7)
* refactor: clean up unused code, fix typos, improve docs

- Remove unused 'killed' const and 'unitTypes' var (staticcheck U1000)
- Replace regexp with strings.TrimSuffix+switch in isFailed for consistency
- Fix typo: 'programatically' -> 'programmatically'
- Fix typo: 'an an int' -> 'as an int' in README and helpers.go
- Add missing godoc comments on exported helper functions
- Bump minimum Go version from 1.18 to 1.21

* refactor: use unused constants instead of removing them

- Export unitTypes as UnitTypes and add HasValidUnitSuffix helper
- Use killed const (exit code 130) in execute() to detect SIGINT
- Update go.mod to go 1.26
v1.1.0
2026-02-23 00:01:59 -05:00
Dat Boi Diego 14c9f0f70d chore: add "support" for non-linux platforms (#6) 2025-09-20 19:34:22 -04:00
Tai Groot 5f1537f8bc Merge pull request #4 from MatthiasKunnen/build-lines
Fix build lines conflict with go toolchain version
2025-05-23 14:48:39 -07:00
Matthias Kunnen d38d347cc6 Fix build lines conflict with go toolchain version
21fce7918e adds build tags, however,
these specific tags are not supported in the go version set in go.mod (1.12).
See <https://go.dev/doc/go1.17#build-lines> and <https://go.dev/doc/go1.18#go-build-lines>.
2025-05-23 17:29:00 +02:00
Tai Groot 14a2ca2acd add placehomer unexported unittypes for later 2025-02-18 00:34:16 -08:00
Tai Groot 451a949ace add new properties, socket finder v1.0.10 2025-02-18 00:30:12 -08:00
Tai Groot 21fce7918e add linux build tags to restrict compilation to linux targets v1.0.9 2025-02-13 16:49:49 -08:00
Tai Groot 54f4f7a235 add IsSystemd checker v1.0.8 2025-02-12 19:21:48 -08:00
Tai Groot fa15432121 add ability to list all units v1.0.7 2024-08-08 15:37:04 -07:00
Tai Groot 7bd5bef0cb fix broken error filtration v1.0.6 2023-06-28 23:43:20 -07:00
Tai Groot a82f845b84 add IsRunning helper v1.0.5 2023-06-20 23:49:23 -04:00
Tai Groot c9e7f79f8c add IsMasked utility 2023-06-20 23:40:22 -04:00
Tai Groot 0075dc6b4d update to fix some tests, remove panics, and wrap errors 2023-06-17 23:18:28 -04:00
Tai Groot 5da4924315 gofumpt against remaining go files v1.0.4 2022-10-23 23:28:19 -07:00
Tai Groot 33828cf7b9 gofumpt against systemctl + add reenable 2022-10-23 23:26:52 -07:00
Tai Groot e44344ee7d define unit in README 2022-03-20 23:44:30 -07:00
Tai Groot c8050d2258 fix whitespace 2022-03-20 23:43:30 -07:00
Tai Groot ae23e6ecb9 Fix lowercase typo 2022-03-20 23:42:35 -07:00
Tai Groot c9dec8a0b7 Update README to fix namespace error 2022-03-20 23:41:14 -07:00
Tai Groot f10c42cec1 update go compiler target version v1.0.3 2021-08-17 10:08:09 -07:00
Tai Groot f1979375cd add sponsorship 2021-07-05 21:08:33 -07:00
Tai Groot 4e38d03629 move panic from init to exec v1.0.2 2021-06-06 04:55:07 -07:00
Tai Groot 701893ebbd Properly return the zero time for invalid timestamps v1.0.1 2021-05-17 10:59:09 -07:00
Tai Groot a32749ff89 Feature complete. Tests may change now, but API is frozen. v1.0.0 2021-05-17 00:46:59 -07:00
Tai Groot 15305985ee Adds Start tests 2021-05-16 23:59:09 -07:00
Tai Groot 3f10bbd46e Adds tests for Restart 2021-05-16 23:54:07 -07:00
Tai Groot ab748adefc Finishes Mask tests 2021-05-16 23:44:21 -07:00
Tai Groot 125e4771dd cleans up comments, adds short testing options to more tests 2021-05-16 23:19:59 -07:00
Tai Groot 54b77122a5 Stubs out remainder of tests 2021-05-16 23:08:42 -07:00
Tai Groot c7b2246a46 Finishes IsEnabled test cases 2021-05-16 23:01:23 -07:00
Tai Groot 60ac9b7400 finishes IsActive tests 2021-05-16 22:36:11 -07:00
Tai Groot 27c2ad77c8 improves IsActive testing 2021-05-16 22:32:24 -07:00
Tai Groot e941c90f0d Migrates many tests to errors_test 2021-05-16 22:00:50 -07:00
Tai Groot dd48d610dc Adds helper function for getting NRestarts 2021-05-16 19:41:44 -07:00
Tai Groot 1ce6ec028a Add documentation and enable example 2021-05-16 18:04:21 -07:00
Tai Groot 6b8241ed7c Make IsEnabled match the documentation 2021-05-16 17:20:03 -07:00
Tai Groot 3fcd88d966 Clean up errors and messages 2021-05-16 16:17:12 -07:00
Tai Groot 7325dda66d Export UserMode options 2021-05-16 15:53:54 -07:00
Tai Groot 399f21f9b9 spellcheck on README 2021-05-15 20:22:48 -07:00
Tai Groot 6940870de8 Revert "Create go.yml"
This reverts commit 84dc669dda.
2021-05-15 20:22:40 -07:00
Tai Groot 84dc669dda Create go.yml 2021-05-16 03:18:49 +00:00
Tai Groot c0d19bd507 spellcheck on README 2021-05-15 20:15:52 -07:00
Tai Groot 45fda65ede updates to README 2021-05-15 20:13:36 -07:00
Tai Groot e7bbc166c3 Updates readme to reflect implementation 2021-05-15 20:06:27 -07:00
Tai Groot 58970695b4 add masked check to isEnabled boolean 2021-05-15 20:04:46 -07:00
Tai Groot 34f11bfcd1 Add masked unit tests for enable and disable 2021-05-15 20:02:05 -07:00
Tai Groot 5865d30ada marked show tests as parallel 2021-05-15 19:19:23 -07:00
Tai Groot 184bbc4936 Test disable function 2021-05-15 19:14:53 -07:00