Rework where the banner output happens

This commit is contained in:
Mike Auty
2026-05-01 15:05:37 +01:00
parent 6b497259a9
commit 392df7745e
+12 -8
View File
@@ -30,11 +30,10 @@ try:
except ImportError:
HAS_ARGCOMPLETE = False
from volatility3.cli import text_filter
import volatility3.plugins
import volatility3.symbols
from volatility3 import framework
from volatility3.cli import text_renderer, volargparse
from volatility3.cli import text_filter, text_renderer, volargparse
from volatility3.framework import (
automagic,
configuration,
@@ -380,6 +379,17 @@ class CommandLine:
)
self.populate_requirements_argparse(plugin_parser, plugin_list[plugin])
# One last pass to get the renderer after we've loaded up plugins,
# so we can determine whether to show the banner on normal output or not...
known_args = [arg for arg in sys.argv[1:] if arg != "--help" and arg != "-h"]
partial_args, _ = parser.parse_known_args(known_args)
# Display banner - redirect to stderr if using structured output
banner_output = sys.stdout
if renderers[partial_args.renderer].structured_output:
banner_output = sys.stderr
banner_output.write(f"Volatility 3 Framework {constants.PACKAGE_VERSION}\n")
###
# PASS TO UI
###
@@ -392,12 +402,6 @@ class CommandLine:
argcomplete.autocomplete(parser)
args = parser.parse_args()
# Display banner - redirect to stderr if using structured output
banner_output = sys.stdout
if renderers[args.renderer].structured_output:
banner_output = sys.stderr
banner_output.write(f"Volatility 3 Framework {constants.PACKAGE_VERSION}\n")
if args.plugin is None:
parser.error(
f"Please select a plugin to run (see '{self.CLI_NAME} --help' for options"