Conversation
Waiting for CLA signature by @snobear @snobear - We require a Contributor License Agreement (CLA) for people who contribute to Puppet, but we have an easy click-through license with instructions, which is available at https://cla.puppetlabs.com/ Note: if your contribution is trivial and you think it may be exempt from the CLA, please post a short reply to this comment with details. http://docs.puppetlabs.com/community/trivial_patch_exemption.html |
CLA signed by all contributors. |
This is interesting but could the behaviour be gated around an additional option which would default to false. Listing some directories can be expensive so it'd be better as a behaviour that the user has to opt-in to. |
@richardc yes that's a good idea. it's expensive and the output could get verbose if there are a bunch of files in that directory. How about an option called |
Seems like the correct switch, as it controls the dir_listing member being present. |
…al, with false as the default.
Added a Question: Is there a way to completely hide the "Directory Listing" if its not applicable, i.e. if its just a single file and not a dir? A conditional display of "Directory Listing" if you will :). If not, something like I have in place seems informative enough. |
Hide it from what/where? |
Hide it from the output. If you're just checking the status of a file, i.e. a non-directory, it doesn't apply. Anyway, scratch that. Here is what it currently does for file vs directory. Let me know your thoughts on where you think this feature stands. File
Directory
|
dir_filelist -= [".",".."] | ||
reply[:dir_listing] = dir_filelist | ||
else | ||
reply[:dir_listing] = "nil (use dirlist=true option to display files in #{file})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is optional, simply don't supply this when the user hasn't asked for it. That is to say lose the entire else condition.
Makes sense. I removed the else condition, and set the default value of the dirlist output to just nil. |
You shouldn't need a default if you just mark it as optional. |
… value instead of just the presence of dirlist option
Gotcha. I removed the defaults and fixed some other small discrepancies. |
@@ -95,7 +101,7 @@ action "status", :description => "Basic information about a file" do | |||
:description => "File group", | |||
:display_as => "Group" | |||
|
|||
output :type, | |||
:description => "File type", | |||
:display_as => "Type" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, are you sure you wanted to remove the specification for the :type field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, thanks for catching that. Not sure how that happened. I'm out of town but will fix and push on Monday.=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - sorry for the slow turnaround, this week got away from me a bit.
@richardc fixed and ran some tests. |
This all looks good, could you squash it down into one commit and I'll merge. |
Squashed. Let me know if you need anything else. |
list directory contents if is directory
Merged. Thanks for the contribution. |
I added a small feature to display a file listing if the given file is of type directory. This is useful for me and perhaps others, so here you go if you're interested!