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
daisylb opened this issue Feb 24, 2013 · 13 comments
Closed

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

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

Comments

@daisylb
Copy link

daisylb 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 commented Mar 16, 2013

👍

@graffic
Copy link
Contributor

graffic commented Dec 17, 2013

Ohhhh, 👍 👍 👍

@jonmarkprice
Copy link

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 commented Sep 23, 2016

Would be useful for scripts replacing simple Make files.

@floam
Copy link
Member

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 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 commented Sep 23, 2016

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

@floam
Copy link
Member

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 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

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.

@daisylb
Copy link
Author

daisylb 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

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

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 pushed a commit to develop7/fish-shell that referenced this issue Apr 17, 2017
@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
Development

No branches or pull requests

8 participants