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

Add a way to get a function's description from a shell script #597

Closed
excitedleigh opened this issue Feb 24, 2013 · 13 comments
Closed

Add a way to get a function's description from a shell script #597

excitedleigh opened this issue Feb 24, 2013 · 13 comments
Assignees
Labels
Milestone

Comments

@excitedleigh
Copy link

@excitedleigh excitedleigh commented Feb 24, 2013

Currently, the only way to do this is (as far as I can tell) is by parsing the full output of functions to pull out the argument to --description (eg functions $func_name | head -n 1 | sed -E "s|.*'(.*)'.*|\1|").

@terlar
Copy link
Contributor

@terlar terlar commented Mar 16, 2013

👍

@graffic
Copy link
Contributor

@graffic graffic commented Dec 17, 2013

Ohhhh, 👍 👍 👍

@jonmarkprice
Copy link

@jonmarkprice jonmarkprice commented Apr 17, 2016

👍

Wrote up a Fish function over on https://github.com/jonmarkprice/fish-functions/blob/master/desc.fish based on @adambrenecki's comment. But obviously it would make more sense for there to be an option as part of the functions command.

@8tt
Copy link

@8tt 8tt commented Sep 23, 2016

Would be useful for scripts replacing simple Make files.

@floam
Copy link
Member

@floam floam commented Sep 23, 2016

It's terribly unpleasant what it does, but you might find __fish_describe_command useful.

@floam
Copy link
Member

@floam floam commented Sep 23, 2016

OK, I'm surprised, that doesn't do what I imagined it would after actually looking at it. Nevermind!

@floam
Copy link
Member

@floam floam commented Sep 23, 2016

Probably if you give functions -d one argument it should output the description.

@floam
Copy link
Member

@floam floam commented Sep 23, 2016

interesting: functions -d foo any_command_with_a_description - doesn't actually seem to affect the description shown in the pager for me.

@floam
Copy link
Member

@floam floam commented Sep 23, 2016

What description should fish_indent have?

$ functions fish_indent
function fish_indent --description 'Indenter and prettifier for fish code'
...
$ complete -Cfish_indent
fish_indent Executable, 1.4MB

seen in pager for fish_<TAB>:

fish_indent                         (-- indenter and prettifier)
@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Dec 13, 2016

Introspection is a useful tool. This is similar to issue #3295 and should be implemented just on general principal. Having said that I'm wondering what the use case is for this feature.

@excitedleigh
Copy link
Author

@excitedleigh excitedleigh commented Feb 17, 2017

Virtualfish has a single vf command with a bunch of subcommands. Internally, the subcommands are all functions with names like __vf_x (since fish doesn't have namespaces or private functions), and we parse out the function description to display help text.

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Feb 17, 2017

We now support functions --metadata --verbose $func_name. It currently does not report the function description. Adding the description to its output is an obvious enhancement. Presumably it should use the same encoding/escaping mechanism that type $func_name uses to deal with descriptions that contain newlines or other special characters. As in this example:

$ function wtf --description '[]{}$abc
      def'
      echo yes
  end
$ type wtf
wtf is a function with definition
function wtf --description \[\]\{\}\$abc\ndef
    echo yes
end

A pull-request to implement that would be welcomed.

@krader1961 krader1961 self-assigned this Mar 13, 2017
@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Mar 13, 2017

I have a proof of concept implementation that addresses this issue by building on the functions --metadata implementation I implemented the fix for issue #3295 a month ago. I need to add some unit tests but expect to merge this in the next few days.

@faho faho modified the milestones: 2.6.0, fish-future Mar 29, 2017
develop7 added a commit to develop7/fish-shell that referenced this issue Apr 17, 2017
@laughedelic laughedelic mentioned this issue Aug 7, 2017
1 of 2 tasks complete
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.