snivilised / cobrass

🐲 Assistant for cli applications using cobra
https://pkg.go.dev/github.com/snivilised/cobrass
MIT License
1 stars 0 forks source link

implement check-sig #194

Closed plastikfan closed 12 months ago

plastikfan commented 1 year ago

Define golang version of Checkpoint-ParamSetSignatures(check-sig)

Define a new sign Boolean flag.

If sign used as standalone, it should acquire existing content so should be provided with a path, extract the signature then calc the hash

If sign used with gen, then we have 2 scenarios:

This means there are 2 ways for sign to acquire its input

However, we could change this and say that sign only works from the input string not a path, but if do this then the implication of this is as follows:

If using standalone, it implies we need the generator so the input string could be acquired. This seems a bit wrong, so instead we can create a checker object that can run from a pre existing path, or can run from an input string. The former can be created in terms of the latter. That is to say we have a checker.parse, this creates the input string and the we have a checker.hash, which runs from the input string created by checker.parse.

The checker needs to run from multiple sources (option-validator-auto(gen-ov), param-set-auto(gen-ps) and param-set-binder-helpers-auto(gen-help)). Currently, only option-validator-auto(gen-ov) is implemented (the others to follow).

Like the generator, sign needs to determine it's input path depending on the presence of the -Test flag. If present, then the input is taken from the pre-defined generation output which is at ./generators/gola/out/assistant. When not present, the the input will be taken from the repo source code at ./src/assistant. However, if the user has not specified the --write flag, then no output will have been generated, so the source is derived from the internal input string. The generator will have to generate these multiple inputs.

We should define unit tests from these requirements and proceed with a tdd approach which hopefully leads to a better emergent design.

⚠️ Whilst working on this issue, I noticed a new major version of Go(v1.21). So the ci workflow has been updated to use 1.21. Also note that the version of golangci-lint in pre-commit hook config needs to be updated to v1.54.2 (formerly v1.52.2) to resolve an issue with depcheck. This needs to be applied to all other repos.