Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: source command as flag for delve (before entering dlv prompt) #3076

Closed
johnsaigle opened this issue Jul 25, 2022 · 2 comments

Comments

@johnsaigle
Copy link

I really love automating things and I'd like to be able to directly invoke a Delve script without manually entering the delve prompt first.

e.g. instead of

$ dlv attach $pid # in bash
...
(dlv) source dlv-script.txt # in dlv

I'd like to do:

dlv attach $pid --source dlv-script.txt

Context

My use case would be to automatically generate an external list of functions for a new project. Currently that looks like this:

gen-funcs.sh

# do some set up, get pid... 
dlv attach $pid

gen-funcs.dlv

transcript -x funcs.out
funcs

Now in Delve prompt:

(dlv) source gen-funcs.dlv
(dlv) exit

I'd like to avoid the need to manually enter a Delve prompt, type my command, and immediately exit when I'm finished.

Related: #2324

@aarzilli
Copy link
Member

aarzilli commented Jul 25, 2022

The --init flag does this. This reduces to #2324. Reopen if I'm wrong.

@johnsaigle
Copy link
Author

Confirmed, thank you. dlv attach $pid --init dlv-script.txt does what I want it to.

I'd recommend adding a bit more documentation to the --init flag (and possibly renaming/aliasing it to --source) for clarity. Before opening the issue I looked at the CLI help and the repository documentation and it wasn't clear to me that init performs this function.

Thanks again!

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

No branches or pull requests

2 participants