disable TOC by default (iconutil doesn't create it either)
This commit is contained in:
@@ -35,7 +35,7 @@ positional arguments:
|
|||||||
icnsutil e Existing.icns -o ./outdir/
|
icnsutil e Existing.icns -o ./outdir/
|
||||||
|
|
||||||
# compose
|
# compose
|
||||||
icnsutil c New.icns 16x16.png 16x16@2x.png *.jp2
|
icnsutil c New.icns 16x16.png 16x16@2x.png *.jp2 --toc
|
||||||
|
|
||||||
# update
|
# update
|
||||||
icnsutil u Existing.icns -rm toc ic04 ic05
|
icnsutil u Existing.icns -rm toc ic04 ic05
|
||||||
@@ -78,7 +78,7 @@ img = icnsutil.IcnsFile('Existing.icns')
|
|||||||
img.add_media('icp4', file='16x16.png', force=True)
|
img.add_media('icp4', file='16x16.png', force=True)
|
||||||
if img.remove_media('TOC '):
|
if img.remove_media('TOC '):
|
||||||
print('table of contents removed')
|
print('table of contents removed')
|
||||||
img.write('Existing.icns', toc=False)
|
img.write('Existing.icns', toc=True)
|
||||||
|
|
||||||
# print
|
# print
|
||||||
icnsutil.IcnsFile.description(fname, indent=2)
|
icnsutil.IcnsFile.description(fname, indent=2)
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class IcnsFile:
|
|||||||
del self.media[key]
|
del self.media[key]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def write(self, fname: str, *, toc: bool = True) -> None:
|
def write(self, fname: str, *, toc: bool = False) -> None:
|
||||||
''' Create a new ICNS file from stored media. '''
|
''' Create a new ICNS file from stored media. '''
|
||||||
# Rebuild TOC to ensure soundness
|
# Rebuild TOC to ensure soundness
|
||||||
order = self._make_toc(enabled=toc)
|
order = self._make_toc(enabled=toc)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def cli_compose(args: ArgParams) -> None:
|
|||||||
img = IcnsFile()
|
img = IcnsFile()
|
||||||
for x in enum_with_stdin(args.source):
|
for x in enum_with_stdin(args.source):
|
||||||
img.add_media(file=x)
|
img.add_media(file=x)
|
||||||
img.write(dest, toc=not args.no_toc)
|
img.write(dest, toc=args.toc)
|
||||||
|
|
||||||
|
|
||||||
def cli_update(args: ArgParams) -> None:
|
def cli_update(args: ArgParams) -> None:
|
||||||
@@ -182,13 +182,13 @@ def main() -> None:
|
|||||||
cmd = add_command('compose', 'c', cli_compose)
|
cmd = add_command('compose', 'c', cli_compose)
|
||||||
cmd.add_argument('-f', '--force', action='store_true',
|
cmd.add_argument('-f', '--force', action='store_true',
|
||||||
help='force overwrite output file')
|
help='force overwrite output file')
|
||||||
cmd.add_argument('--no-toc', action='store_true',
|
cmd.add_argument('--toc', action='store_true',
|
||||||
help='do not write table of contents to file')
|
help='write table of contents to file')
|
||||||
cmd.add_argument('target', type=str, metavar='destination',
|
cmd.add_argument('target', type=str, metavar='destination',
|
||||||
help='Output file for newly created icns file.')
|
help='Output file for newly created icns file.')
|
||||||
cmd.add_argument('source', type=PathExist('f', stdin=True), nargs='+',
|
cmd.add_argument('source', type=PathExist('f', stdin=True), nargs='+',
|
||||||
metavar='src',
|
metavar='src',
|
||||||
help='One or more media files: png, argb, plist, icns.')
|
help='One or more media files: png, argb, rgb, jp2, icns')
|
||||||
cmd.epilog = '''
|
cmd.epilog = '''
|
||||||
Notes:
|
Notes:
|
||||||
- TOC is optional but only a few bytes long (8b per media entry).
|
- TOC is optional but only a few bytes long (8b per media entry).
|
||||||
|
|||||||
Reference in New Issue
Block a user