Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

In p4, exchange the meaning of -c and -C

  • Loading branch information...
commit e0f5ed14714b14c79dfedd2384866cfc755e628a 1 parent 75f2f12
@pinard authored
Showing with 25 additions and 31 deletions.
  1. +2 −2 Makefile
  2. +13 −18 p4
  3. +10 −11 p4.rst.in
View
4 Makefile
@@ -7,7 +7,7 @@ PYTHON = python
RST2LATEX = rst2latex
PYSETUP = $(PYTHON) setup.py
-P4 = $(PYTHON) p4 -c p4config.py
+P4 = $(PYTHON) p4 -C p4config.py
all:
$(P4) *.in Pymacs contrib tests
@@ -27,7 +27,7 @@ install:
clean: clean-debug
rm -rf build* contrib/rebox/build
rm -f */*py.class */*.pyc p4.pdf pymacs.pdf
- $(P4) -C *.in Pymacs contrib tests
+ $(P4) -c *.in Pymacs contrib tests
clean-debug:
rm -f tests/debug-protocol tests/debug-signals
View
31 p4
@@ -12,14 +12,14 @@ Usage: p4 -m [OPTION]... FILE1 FILE2
General options:
-h Print this help and do nothing else
-m Produce, on standard output, a merged version
- -C Clean files which would normally have been produced
+ -c Clean files which would normally have been produced
-v Be verbose about written (or deleted) files
-f Force deletion of rewriting, even if files were modified
Context setting options:
- -c FILE Evaluate Python FILE for preparing context
- -Dname Define "name" as True
- -Dname=expr Define "name" as the value of Python "expr"
+ -C FILE Evaluate Python FILE for preparing context
+ -D name Define "name" as True
+ -D name=expr Define "name" as the value of Python "expr"
Transformation options:
-o OUTPUT Collect output files into the OUTPUT directory
@@ -33,12 +33,11 @@ merged and the result written to standard output, augmented as needed
with "if name:", "if not name:" and "else:" directives, such that FILE1
is meant when "name" is False, FILE2 is meant when "name" is True.
-Without -Cm, files go through an elementary pre-processing. If no FILE
+Without -cm, files go through an elementary pre-processing. If no FILE
is given, standard input is transformed and written to standard output.
-Otherwise, each FILE is either a file or a directory. Directories are
-recursively traversed for the contained file names. Whatever if a file
-is directly or indirectly named, it is retained for transformation only
-when it's full path name (starting at FILE and down) has a component for
+Otherwise, if FILE is a directory, it is recursively traversed for the
+files it contains. A file is eligible for transformation only when
+it's full path name (starting at FILE and down) has a component for
which there is a '.in' suffix. The file receiving a transformed file
is derived removing all such '.in' suffixes, and prepending OUTPUT as a
directory if specified. Output directories are created as needed.
@@ -75,22 +74,18 @@ class Main:
def main(self, *arguments):
import getopt
- options, arguments = getopt.getopt(arguments, 'CD:c:fhi:mno:ps:v')
+ options, arguments = getopt.getopt(arguments, 'C:D:cfhi:mno:ps:v')
for option, value in options:
if option == '-C':
- self.clean = True
+ exec(compile(open(value).read(), value, 'exec'), self.context)
elif option == '-D':
if '=' in value:
name, value = value.split('=', 1)
- value = eval(value, {})
+ self.context[name] = eval(value, {})
else:
- name = value
- value = True
- if name in self.context and value != self.context[name]:
- sys.exit("More than one value for %s" % name)
- self.context[name] = value
+ self.context[name] = True
elif option == '-c':
- exec(compile(open(value).read(), value, 'exec'), self.context)
+ self.clean = True
elif option == '-f':
self.force = True
elif option == '-h':
View
21 p4.rst.in
@@ -128,7 +128,7 @@ commands::
p4 [OPTION]... [ARGUMENT]...
The operating mode of the program, and the meaning of arguments, depend
-on some options being used or not. Option ``-C`` forces clean out
+on some options being used or not. Option ``-c`` forces clean out
mode, option ``-m`` forces merge mode. Otherwise, the program uses the
pre-processing mode.
@@ -143,17 +143,16 @@ Setting the context
-------------------
The context used for the pre-processing is initially empty. It does not
-even have Python builtins. It is then filled through the use of ``-c``
-or ``-D`` options.
+even have Python builtins. It is then filled through the use of ``-C``
+or ``-D`` options, which may be repeated when there are many definitions
+to introduce, or when there is a need to override previous settings.
Option ``-D`` :var:`name` adds :var:`name` into the context, associating
it with the Python value ``True``. Option ``-D`` :var:`name`\ ``=``\
-:var:`expr` adds :var:`name` into the context, associating with the value of
-the Python expression :var:`expr`. ``-D`` option may be used more than
-once when there are many definitions to introduce. Beware of Python
-characters which also have a meaning for the shell, proper quoting may
-be needed. Here is, for example, how to define a string while calling
-:code:`p4`::
+:var:`expr` adds :var:`name` into the context, associating with the
+value of the Python expression :var:`expr`. Beware of Python characters
+which also have a meaning for the shell, proper quoting may be needed.
+Here is, for example, how to define a string while calling :code:`p4`::
p4 -D "version='0.24-beta2'" ...
@@ -182,7 +181,7 @@ might not be what you wanted.
Pre-processing files
--------------------
-Without options ``-C`` or ``-m``, the arguments to the program indicate
+Without options ``-c`` nor ``-m``, the arguments to the program indicate
which files are going to be pre-processed. If there is no argument
at all, this is a special case by which standard input is read,
pre-processed and then written to standard output.
@@ -253,7 +252,7 @@ Cleaning out files
------------------
As a convenience for :file:`Makefile` writers, there is an option to
-help at cleaning out derived files. With ``-C`` specified, any file that
+help at cleaning out derived files. With ``-c`` specified, any file that
would have been produced in pre-processing mode is removed instead.
Of course, to be useful, the command arguments naming files or
Please sign in to comment.
Something went wrong with that request. Please try again.