diff options
| author | Karel Zak <kzak@redhat.com> | 2024-12-02 12:02:38 +0100 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2024-12-09 10:25:06 +0100 |
| commit | 5d0edf55b62f8f9ac9d58539014ea5c292df8291 (patch) | |
| tree | 91def32feb55fa5797802626fcbd4b8da3add6d9 /misc-utils/lsblk.c | |
| parent | 8e54820c10a7e90316fc5e1abf52fbde9c4fd52d (diff) | |
| download | util-linux-5d0edf55b62f8f9ac9d58539014ea5c292df8291.tar.gz | |
lsblk: add --hyperlink command line option
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
| -rw-r--r-- | misc-utils/lsblk.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index cc1ae98b6c..6a8dc5011b 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1274,10 +1274,14 @@ static void device_fill_scols_cell(struct lsblk_device *dev, ce = scols_line_get_cell(ln, colnum); if (!ce) return; + rc = datasiz ? scols_cell_refer_memory(ce, data, datasiz) : scols_cell_refer_data(ce, data); if (rc) err(EXIT_FAILURE, _("failed to add output data")); + + if (lsblk->uri && (id == COL_TARGETS || id == COL_TARGET) && dev->is_swap) + scols_cell_disable_uri(ce, 1); } static int filter_filler_cb( @@ -2407,7 +2411,8 @@ int main(int argc, char *argv[]) OPT_COUNTER_FILTER, OPT_COUNTER, OPT_HIGHLIGHT, - OPT_PROPERTIES_BY + OPT_PROPERTIES_BY, + OPT_HYPERLINK }; static const struct option longopts[] = { @@ -2424,6 +2429,7 @@ int main(int argc, char *argv[]) { "output-all", no_argument, NULL, 'O' }, { "filter", required_argument, NULL, 'Q' }, { "highlight", required_argument, NULL, OPT_HIGHLIGHT }, + { "hyperlink", optional_argument, NULL, OPT_HYPERLINK }, { "merge", no_argument, NULL, 'M' }, { "perms", no_argument, NULL, 'm' }, { "noheadings", no_argument, NULL, 'n' }, @@ -2667,6 +2673,11 @@ int main(int argc, char *argv[]) if (lsblk_set_properties_method(optarg) < 0) errtryhelp(EXIT_FAILURE); break; + case OPT_HYPERLINK: + if (hyperlinkwanted_or_err(optarg, + _("invalid hyperlink argument"))) + lsblk->uri = xgethosturi(NULL); + break; case 'H': collist = 1; break; @@ -2793,6 +2804,9 @@ int main(int argc, char *argv[]) if (fl & SCOLS_FL_WRAP) scols_column_set_wrapfunc(cl, NULL, scols_wrapzero_nextchunk, NULL); + if (lsblk->uri && (id == COL_TARGET || id == COL_TARGETS)) + scols_column_set_uri(cl, lsblk->uri); + set_column_type(ci, cl, fl); } |
