comparison mercurial-common/src/python/load-commands-command.py @ 828:8d02c7b1f812

use HG extension to pass infinite commandline arguments list
author eugene.petrenko@jetbrains.com
date Fri, 30 May 2014 17:29:51 +0200
parents
children ef19cc8d5bc1
comparison
equal deleted inserted replaced
827:194c8f8d6e4c 828:8d02c7b1f812
1 #!/usr/bin/env python
2 ##
3 ## Copyright 2000-2014 JetBrains
4 ##
5 ## Licensed under the Apache License, Version 2.0 (the "License");
6 ## you may not use this file except in compliance with the License.
7 ## You may obtain a copy of the License at
8 ##
9 ## http://www.apache.org/licenses/LICENSE-2.0
10 ##
11 ## Unless required by applicable law or agreed to in writing, software
12 ## distributed under the License is distributed on an "AS IS" BASIS,
13 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ## See the License for the specific language governing permissions and
15 ## limitations under the License.
16 ##
17 ##
18 ## http://www.gnu.org/licenses/gpl-faq.html#GPLModuleLicense
19 ## http://www.gnu.org/licenses/license-list.html#apache2
20 ## http://en.wikipedia.org/wiki/Apache_License#GPL_compatibility
21 ##
22 ##
23 """
24 load-commands-command
25 """
26
27 import codecs
28 from mercurial import dispatch
29
30 def loadArguments(ui, params_file):
31 file_commands = []
32 ui.write("Parameters from the file (one by line):\n")
33 with codecs.open(params_file, "r", "utf-8") as f:
34 for _line in f:
35 line = _line.strip()
36 if len(line) <= 0:
37 continue
38
39 ui.write(" " + line + "\n")
40 file_commands.append(line)
41 return file_commands
42
43
44 def load_commands_command(ui, repo, params_file, *pats, **opts):
45 ui.write("Staring command with arguments from " + params_file + "\n")
46 command_arguments = loadArguments(ui, params_file)
47
48 ui.write("\nRunning the command...\n\n")
49 return dispatch.dispatch(dispatch.request(command_arguments))
50
51 #so here goes command registration and options
52 cmdtable = {
53 "CMD": (load_commands_command, [ ], "params_file [foo]...")
54 }
55
56 testedwith = '2.2.2'
57 buglink = "@jonnyzzz"
58