Following #59 (Search "Sidebar -- docopts.sh entrypoint wrapper" heading)
We discussed how to embed docopts.sh wrapper into docopts binary itself. One of the purpose is to keep a single standalone binary. May be it could also open some new feature and or behavior. So lets explore.
Pros
- both
docopts and shell helper at the same place
- coherent with example
- could be also outputted as
evaled content
- could be stored in the
$PATH too at user preference ex: docopts get-wrapper docopts.sh > $HOME/bin/docopts.sh
Cons
- huge impact on
eval if the code is also evaled at run time
Go sample code
package main
import (
_ "embed"
"fmt"
)
//go:embed docopts.sh
var docopts_sh string
func main() {
fmt.Println(docopts_sh)
}
Go code ref
https://pkg.go.dev/embed
https://go.dev/src/fmt/print.go
golang/go#28822 - discussion about automatic handling NEWLINE
https://en.wikipedia.org/wiki/Newline#Representation (seems macos moved to \n)
from issue above: notepad seems windows 10 to support \n
May 8th, 2018 - https://devblogs.microsoft.com/commandline/extended-eol-in-notepad/
Following #59 (Search "
Sidebar -- docopts.sh entrypoint wrapper" heading)We discussed how to embed
docopts.shwrapper intodocoptsbinary itself. One of the purpose is to keep a single standalone binary. May be it could also open some new feature and or behavior. So lets explore.Pros
docoptsand shell helper at the same placeevaledcontent$PATHtoo at user preference ex:docopts get-wrapper docopts.sh > $HOME/bin/docopts.shCons
evalif the code is also evaled at run timeGo sample code
Go code ref
https://pkg.go.dev/embed
https://go.dev/src/fmt/print.go
golang/go#28822 - discussion about automatic handling NEWLINE
https://en.wikipedia.org/wiki/Newline#Representation (seems macos moved to
\n)from issue above: notepad seems windows 10 to support
\nMay 8th, 2018 - https://devblogs.microsoft.com/commandline/extended-eol-in-notepad/