-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_args.py
executable file
·35 lines (25 loc) · 1.02 KB
/
write_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Python script to output the given list as a space-delimited string to a file.
path/to/write_args.py --output filename -- arg1 arg2 ...
will output the args to the file.
This script is used from common-mk/deps.gni .
TODO(oka): Remove this file and replace the invocation with write_file if
space-delimiting option is added to it.
https://bugs.chromium.org/p/gn/issues/detail?id=9
"""
from __future__ import print_function
import argparse
import sys
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', required=True, help='the output file name')
parser.add_argument('args', nargs='*')
options = parser.parse_args(argv)
with open(options.output, 'w') as f:
f.write(' '.join(options.args) + '\n')
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))