2020-12-02 17:11:24 -05:00
|
|
|
package cmdarg
|
2020-11-28 09:06:03 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"io"
|
2023-10-15 22:23:50 -04:00
|
|
|
"os"
|
2020-11-28 09:06:03 -05:00
|
|
|
)
|
|
|
|
|
2020-12-02 17:11:24 -05:00
|
|
|
// LoadArg loads one arg, maybe an remote url, or local file path
|
|
|
|
func LoadArg(arg string) (out io.Reader, err error) {
|
|
|
|
bs, err := LoadArgToBytes(arg)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
out = bytes.NewBuffer(bs)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadArgToBytes loads one arg to []byte, maybe an remote url, or local file path
|
|
|
|
func LoadArgToBytes(arg string) (out []byte, err error) {
|
2023-10-15 22:23:50 -04:00
|
|
|
out, err = os.ReadFile(arg)
|
2020-11-28 09:06:03 -05:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|