Skip to content

cmd/starlark: add -c flag to execute cmdline program#47

Merged
alandonovan merged 1 commit intogoogle:masterfrom
josharian:dash-c
Dec 7, 2018
Merged

cmd/starlark: add -c flag to execute cmdline program#47
alandonovan merged 1 commit intogoogle:masterfrom
josharian:dash-c

Conversation

@josharian
Copy link
Copy Markdown
Collaborator

-c was chosen to match Python. Sample:

$ starlark -c "print(max(range(10)))"
9
$ starlark -c "a = 'hi'" -showenv
a = "hi"

var (
cpuprofile = flag.String("cpuprofile", "", "gather CPU profile in this file")
showenv = flag.Bool("showenv", false, "on success, print final global environment")
execprog = flag.String("c", "", "execute program `c`")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c (in the usage) should be stmt or prog, perhaps?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to prog. It can be more than one stmt--it can contain semicolons.

var (
cpuprofile = flag.String("cpuprofile", "", "gather CPU profile in this file")
showenv = flag.Bool("showenv", false, "on success, print final global environment")
execprog = flag.String("c", "", "execute prog `c`")
Copy link
Copy Markdown
Contributor

@alandonovan alandonovan Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, you changed program to prog but left c alone. :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh. I'm so scatterbrained right now. Multitasking. Sorry. :( Fixed now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. The "Commit" button on most of these apps might as well be called "Begin spelling review" in my case.

-c was chosen to match Python. Sample:

$ starlark -c "print(max(range(10)))"
9
$ starlark -c "a = 'hi'" -showenv
a = "hi"
@josharian
Copy link
Copy Markdown
Collaborator Author

Hmm, I thought I might have write access, but I guess I was wrong. :)

@alandonovan alandonovan merged commit d1cdecf into google:master Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants