From 3959e5256d7bdfd72ab5356da810ad668fdfc4de Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 22 Jan 2021 19:39:53 +0100 Subject: cmdline: port to argparse --- CHANGES | 3 + pygments/cmdline.py | 309 ++++++++++++++++++++++++-------------------------- tests/test_cmdline.py | 49 ++++---- 3 files changed, 177 insertions(+), 184 deletions(-) diff --git a/CHANGES b/CHANGES index d0465aeb..94e88027 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,9 @@ Version 2.8.0 ------------- (not released yet) +- The `pygmentize` script now uses `argparse`, all options should work + as before + - Added `pygmentize -C` option to guess a lexer from content - Fix escapes in JavaScript and TypeScript backtick strings (#1679, #1686) diff --git a/pygments/cmdline.py b/pygments/cmdline.py index 1a3aa5cb..4c56bf7f 100644 --- a/pygments/cmdline.py +++ b/pygments/cmdline.py @@ -10,7 +10,7 @@ import os import sys -import getopt +import argparse from textwrap import dedent from pygments import __version__, highlight @@ -29,88 +29,6 @@ from pygments.filters import get_all_filters, find_filter_class from pygments.styles import get_all_styles, get_style_by_name -USAGE = """\ -Usage: %s [-l | -g] [-F [:]] [-f ] - [-O ] [-P ] [-s] [-v] [-x] [-o ] [] - - %s -S