From mboxrd@z Thu Jan 1 00:00:00 1970 List-Id: Return-Path: Received: from localhost (localhost [127.0.0.1]) by mail.ignore.pl (Postfix) with ESMTP id C29C1435D7; Mon, 20 Jul 2026 07:37:37 +0000 (UTC) X-Virus-Scanned: Debian amavis at ignore.pl X-Spam-Flag: NO X-Spam-Score: 1.801 X-Spam-Level: * X-Spam-Status: No, score=1.801 tagged_above=1.8 required=4.7 tests=[DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, DMARC_PASS=-0.001, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=1, RCVD_IN_VALIDITY_SAFE_BLOCKED=1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001] autolearn=no autolearn_force=no Received: from mail.ignore.pl ([127.0.0.1]) by localhost (geidontei.ignore.pl [127.0.0.1]) (amavis, port 10024) with ESMTP id zXEozHcOE3Xe; Mon, 20 Jul 2026 07:37:35 +0000 (UTC) Authentication-Results: mail.ignore.pl; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HKZMq7oE; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by mail.ignore.pl (Postfix) with ESMTPS id D0265435D6; Mon, 20 Jul 2026 07:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784533054; x=1816069054; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zqfRA+OKD28M1Bh4GwkxvfZ/b85yD/qgsQsJMTU3oko=; b=HKZMq7oE9CXbVVBY8Rk0/qI1TNJy8a2SeBldmT6v98YNpPn6oGou5n1h 9yvlXVs3LE7zTUpWOGfFKcxTSIDHUjAi6epzbYwJ47Gb9lPq+Lqx5Z71Z xG5v3AZkuXG+NuVZ7z26wge6sS8gefbdPwYKxzLDf1dgx32pCB7163zMl xPo+h7ZXvB77Sp1Y4Kp23YqNGdfoqn0owvxyBkERvKeN/B7fRz8G85AtP 9tvIjb4n0YDjb65kcBLEjJBRm4pYOSrHMo98xFBWvmjRQOqnp1ypow8xH j17HBGQ6Nw+ytbZLMq8x5cznLjyahVayyrKSrbFm5AAlltichSpBsbNjD w==; X-CSE-ConnectionGUID: 7xZCqRXnQNCMIlViwdoUsg== X-CSE-MsgGUID: trXhKl+6QpaHjrHWXUoVfw== X-IronPort-AV: E=McAfee;i="6800,10657,11851"; a="96471783" X-IronPort-AV: E=Sophos;i="6.25,174,1779174000"; d="scan'208";a="96471783" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2026 00:37:31 -0700 X-CSE-ConnectionGUID: LGUXcKIQRfmkGvMWgfDuug== X-CSE-MsgGUID: VBd+GRsgSEC35LcWhUitsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,174,1779174000"; d="scan'208";a="281852393" Received: from hpe-dl385gen10.igk.intel.com ([10.91.240.117]) by fmviesa001.fm.intel.com with ESMTP; 20 Jul 2026 00:37:29 -0700 From: Jakub Slepecki To: patches@ignore.pl Cc: please@ignore.pl, jakub.slepecki@intel.com Subject: [PATCH what] what: add -c option to command-line interface Date: Mon, 20 Jul 2026 09:37:21 +0200 Message-ID: <20260720073721.14907-1-jakub.slepecki@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Content-Transfer-Encoding: 8bit Using require() to load configuration gives some interesting effects, for example, one can add their own what.config in a directory that is tested earlier to inject their own configuration. This avoids some logic needed for a custom config loading behaviour. In a long run, a "traditional" XDG_CONFIG_HOME, HOME, ... may be better, but this is enough to start tinkering with plugins and such. Signed-off-by: Jakub Slepecki --- what.1 | 11 ++++++++++- what.lua | 6 +++--- what/lapp.lua | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/what.1 b/what.1 index af6b18b84b0e..d65028fd656d 100644 --- a/what.1 +++ b/what.1 @@ -3,6 +3,8 @@ what - translates raw information in logs to something human-readable .SH SYNPOSIS .B what +.RB [ \-c +.IR config ] .RI [ file ] .SH DESCRIPTION Translate various blobs or otherwise intangible information into a @@ -10,8 +12,15 @@ human-readable format. .P .I File argument may be pathname or -.B - +.B \- to read from standard input. If left empty it will also read from standard input. +.SH OPTIONS +.B \-c +.I config +.RS +Use a custom configuration module. Default is +.BI what.config . +.RE .SH SEE ALSO .BR dmesg (1) diff --git a/what.lua b/what.lua index cb01fb034170..b26ff459408c 100755 --- a/what.lua +++ b/what.lua @@ -1,11 +1,11 @@ #!/usr/bin/env lua local lapp = require "what.lapp" local args = lapp[[ -Usage: what [] +Usage: what [-c] [] + -c (module default what.config) What config to use (input default -) Pathname or explicit - ]] -local config = require "what.config" local translate = require "what.translate" -translate(config, args.input) +translate(args.c, args.input) io.close(args.input) diff --git a/what/lapp.lua b/what/lapp.lua index 2d27ea7a7960..3e2bb75794d7 100644 --- a/what/lapp.lua +++ b/what/lapp.lua @@ -24,4 +24,18 @@ lapp.add_type( end) +lapp.add_type( + "module", + function (name) + local ok, module = pcall(require, name) + print(name, ok, module) + if not ok then + io.stderr:write( + string.format("what: could not load module: %s\n", name)) + os.exit(1) + end + return module + end) + + return lapp -- 2.43.0