File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import print_function
2
2
3
+ import locale
3
4
import os .path
4
5
import subprocess
5
6
import tempfile
@@ -74,8 +75,13 @@ def edit(filename=None, contents=None):
74
75
def _get_editor (ns ):
75
76
print (get_editor ())
76
77
78
+
77
79
def _edit (ns ):
78
- print (edit ())
80
+ contents = ns .contents
81
+ if contents is not None :
82
+ contents = contents .encode (locale .getpreferredencoding ())
83
+ print (edit (filename = ns .path , contents = contents ))
84
+
79
85
80
86
if __name__ == '__main__' :
81
87
import argparse
@@ -87,6 +93,8 @@ def _edit(ns):
87
93
88
94
cmd = sp .add_parser ('edit' )
89
95
cmd .set_defaults (cmd = _edit )
96
+ cmd .add_argument ('path' , type = str , nargs = '?' )
97
+ cmd .add_argument ('--contents' , type = str )
90
98
91
99
ns = ap .parse_args ()
92
100
ns .cmd (ns )
You can’t perform that action at this time.
0 commit comments