2020-12-06 11:17:12 +00:00
|
|
|
'''
|
|
|
|
Create the file, or update the last modified timestamp.
|
|
|
|
'''
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from voussoirkit import pipeable
|
|
|
|
from voussoirkit import winglob
|
|
|
|
|
|
|
|
def touch_argparse(args):
|
2021-05-25 08:35:55 +00:00
|
|
|
patterns = pipeable.input_many(args.patterns, skip_blank=True)
|
2020-12-06 11:17:12 +00:00
|
|
|
for pattern in patterns:
|
|
|
|
filenames = winglob.glob(pattern)
|
|
|
|
|
|
|
|
if len(filenames) == 0 and not winglob.is_glob(pattern):
|
|
|
|
open(pattern, 'a').close()
|
2021-05-25 08:35:46 +00:00
|
|
|
pipeable.stdout(pattern)
|
2020-12-06 11:17:12 +00:00
|
|
|
|
|
|
|
for filename in filenames:
|
|
|
|
os.utime(filename)
|
2021-05-25 08:35:46 +00:00
|
|
|
pipeable.stdout(filename)
|
2020-12-06 11:17:12 +00:00
|
|
|
|
|
|
|
def main(argv):
|
|
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
|
|
|
|
|
|
parser.add_argument('patterns', nargs='+')
|
|
|
|
parser.set_defaults(func=touch_argparse)
|
|
|
|
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
return args.func(args)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
raise SystemExit(main(sys.argv[1:]))
|