Merge pull request #1874 from rindeal/configure_file-capture
add `capture: true` ability to configure_file()pull/1918/head
commit
3ced977547
7 changed files with 104 additions and 1 deletions
@ -0,0 +1,28 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import sys |
||||
import argparse |
||||
import os |
||||
|
||||
def main(): |
||||
parser = argparse.ArgumentParser() |
||||
parser.add_argument('text', nargs='*', type=str) |
||||
args = parser.parse_args() |
||||
|
||||
text = args.text if isinstance(args.text, list) else [args.text] |
||||
|
||||
output = '' |
||||
for t in text: |
||||
t = os.path.basename(t) |
||||
|
||||
if not output: |
||||
output += t |
||||
else: |
||||
output += ' ' + t |
||||
|
||||
output += '\n' |
||||
|
||||
sys.stdout.write(output) |
||||
|
||||
if __name__ == '__main__': |
||||
sys.exit(main()) |
@ -0,0 +1,22 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import sys |
||||
import argparse |
||||
|
||||
def main(): |
||||
parser = argparse.ArgumentParser() |
||||
parser.add_argument('file', nargs=1, type=str) |
||||
parser.add_argument('text', nargs=1, type=str) |
||||
args = parser.parse_args() |
||||
|
||||
text = args.text[0] |
||||
|
||||
with open(args.file[0], 'r', encoding='utf-8') as f: |
||||
for line in f: |
||||
if line.strip() == text: |
||||
return 0 |
||||
|
||||
return 1 |
||||
|
||||
if __name__ == '__main__': |
||||
sys.exit(main()) |
@ -0,0 +1,16 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import sys |
||||
import argparse |
||||
from pathlib import Path |
||||
|
||||
def main(): |
||||
parser = argparse.ArgumentParser() |
||||
parser.add_argument('files', nargs='*', type=str) |
||||
args = parser.parse_args() |
||||
|
||||
for filepath in args.files: |
||||
Path(filepath).touch() |
||||
|
||||
if __name__ == '__main__': |
||||
sys.exit(main()) |
Loading…
Reference in new issue