Skip to content

embedded docopts.sh wrapper into docopts binary #60

Open
@Sylvain303

Description

@Sylvain303

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/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions