dadadel / pyment

Format and convert Python docstrings and generates patches
GNU General Public License v3.0
905 stars 62 forks source link

Add option for output to STDOUT #80

Closed torfsen closed 4 years ago

torfsen commented 5 years ago

It seems that there is currently no option to output to STDOUT. That would be a nice feature in my opinion, since my usual workflow with tools like this is to first get a quick preview of the proposed changes on STDOUT (usually piped to less) and, if satisfied, apply the changes in-place. Of course I can do that using the generated .patch file, but it's more cumbersome. So I'd love to have a CLI parameter to redirect the output to STDOUT.

dadadel commented 4 years ago

@torfsen Thanks for suggestion, this was already suggested in issue #53 and integrated in PR #59

dadadel commented 4 years ago

Note that if you provide - to pyment as path, it will take its input from stdin and provide its patch output to stdout.

$ echo 'def hello(param1, param2=True): ' | pyment -
# Patch generated by Pyment v0.3.3

--- a/-
+++ b/-
@@ -1 +1,7 @@
 def hello(param1, param2=True): 
+    """
+
+    :param param1: 
+    :param param2:  (Default value = True)
+
+    """

And if you add the -w option it will produce the modified file instead of the patch.

$ echo 'def hello(param1, param2=True): ' | pyment -w -
def hello(param1, param2=True): 
    """

    :param param1: 
    :param param2:  (Default value = True)

    """
dadadel commented 4 years ago

I close the issue as the stdout is available. If this doesn't really suit your use case, feel free to reopen the issue.