Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new file list call &FILELIST where paths are relative to the FILELIST #22

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cogapp/cogapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
usage = """\
cog - generate content with inlined Python code.

cog [OPTIONS] [INFILE | @FILELIST] ...
cog [OPTIONS] [INFILE | @FILELIST | &FILELIST] ...

INFILE is the name of an input file, '-' will read from stdin.
FILELIST is the name of a text file containing file names or
other @FILELISTs.
other @FILELISTs.
For @FILELIST, paths in the file list are relative to
the working directory where cog was called.
For &FILELIST, paths in the file list are relative to
the file list.

OPTIONS:
-c Checksum the output to protect it against accidental change.
Expand Down Expand Up @@ -764,6 +768,14 @@ def processArguments(self, args):
if self.options.sOutputName:
raise CogUsageError("Can't use -o with @file")
self.processFileList(args[0][1:])
elif args[0][0] == '&':
if self.options.sOutputName:
raise CogUsageError("Can't use -o with @file")
saved_cwd = os.getcwd()
file_list = args[0][1:]
os.chdir(os.path.dirname(file_list))
self.processFileList(os.path.basename(file_list))
os.chdir(saved_cwd)
else:
self.processWildcards(args[0])

Expand Down
Loading