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
adambrenecki opened this Issue Feb 24, 2013 · 13 comments

Comments

Projects
None yet
8 participants
@adambrenecki

adambrenecki 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

This comment has been minimized.

Show comment
Hide comment
@terlar

terlar Mar 16, 2013

Contributor

👍

Contributor

terlar commented Mar 16, 2013

👍

@graffic

This comment has been minimized.

Show comment
Hide comment
@graffic

graffic Dec 17, 2013

Contributor

Ohhhh, 👍 👍 👍

Contributor

graffic commented Dec 17, 2013

Ohhhh, 👍 👍 👍

adambrenecki added a commit to adambrenecki/virtualfish that referenced this issue Dec 18, 2013

@jonmarkprice

This comment has been minimized.

Show comment
Hide comment
@jonmarkprice

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

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

This comment has been minimized.

Show comment
Hide comment
@8tt

8tt Sep 23, 2016

Would be useful for scripts replacing simple Make files.

8tt commented Sep 23, 2016

Would be useful for scripts replacing simple Make files.

@floam

This comment has been minimized.

Show comment
Hide comment
@floam

floam Sep 23, 2016

Member

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

Member

floam commented Sep 23, 2016

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

@floam

This comment has been minimized.

Show comment
Hide comment
@floam

floam Sep 23, 2016

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@floam

floam Sep 23, 2016

Member

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

Member

floam commented Sep 23, 2016

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

@floam

This comment has been minimized.

Show comment
Hide comment
@floam

floam Sep 23, 2016

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@floam

floam Sep 23, 2016

Member

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

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Dec 13, 2016

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.

Contributor

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.

@adambrenecki

This comment has been minimized.

Show comment
Hide comment
@adambrenecki

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

adambrenecki 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

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Feb 17, 2017

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Mar 13, 2017

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.

Contributor

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.

krader1961 added a commit to krader1961/fish-shell that referenced this issue Mar 14, 2017

@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 referenced this issue Aug 7, 2017

Closed

Fixed functions -D/--details completion #4289

1 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment