Commit graph

311 commits

Author SHA1 Message Date
Taiju HIGASHI c8803d89fe
ui: Improve pager selection logic when less is not installed.
* guix/ui.scm (find-available-pager): New procedure.
(call-with-paginated-output-port): Use it.
* guix/utils.scm (call-with-environment-variables): Allow clearing of
specified environment variables.
* tests/ui.scm (make-empty-file, assert-equals-find-available-pager):
New procedures.
("find-available-pager, GUIX_PAGER takes precedence")
("find-available-pager, PAGER takes precedence")
("find-available-pager, 'less' takes precedence")
("find-available-pager, 'more' takes precedence")
("find-available-pager, no pager"): New tests.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2022-06-16 23:57:41 +02:00
Ludovic Courtès 5e0c347975
ui: Highlight package and service search results.
* guix/ui.scm (package->recutils): Add #:highlighting parameter and use it.
(display-search-results): Add #:regexps parameter; call
'colorize-full-matches' and pass #:highlighting.
* guix/scripts/package.scm (process-query): Pass #:regexps to
'display-search-results'.
* guix/scripts/home.scm (search): Likewise.
* guix/scripts/system/search.scm (service-type->recutils): Add #:highlighting
parameter and use it.
2022-04-19 18:07:49 +02:00
Ludovic Courtès 00dcfb261b
ui: Highlight important bits in recutils output.
* guix/scripts/system/search.scm (service-type->recutils): Highlight the
value of the 'name' field.
* guix/ui.scm (package->recutils): Likewise for 'name' and 'version'.
2022-04-19 18:07:49 +02:00
Ludovic Courtès 3da62bf5aa
ui: Move 'location->hyperlink' to (guix diagnostics).
* guix/ui.scm (location->hyperlink): Move to...
* guix/diagnostics.scm: ... here.
* guix/scripts/system/search.scm: Adjust imports accordingly.
2022-04-08 23:59:48 +02:00
Ludovic Courtès d4e858763c
ui: Move hyperlink facilities to (guix colors).
* guix/ui.scm (supports-hyperlinks?, file-hyperlink, hyperlink): Move to...
* guix/colors.scm: ... here.
* guix/scripts/home.scm, guix/scripts/system.scm,
guix/scripts/system/search.scm: Adjust imports accordingly.
2022-04-08 23:59:48 +02:00
Ludovic Courtès 625fa3cfe8
ui: 'show-what-to-build' highlights "would be downloaded" headings.
* guix/ui.scm (show-what-to-build): Highlight "X MB would be downloaded".
2022-03-18 16:03:33 +01:00
Ludovic Courtès 9e0f0123a0
ui: 'show-what-to-build' highlights "The following [...] will be built".
* guix/colors.scm (highlight/warn): New procedure.
* guix/ui.scm (show-what-to-build): Use 'highlight/warn' when displaying
what would/will be built.
2022-03-18 16:03:32 +01:00
Ludovic Courtès 5b6e31b020
ui: 'display-generation' uses color when talking to a pager.
This makes sure that, say, 'guix pull -l' benefits from colors when its
output is piped to a pager, as long as the underlying terminal supports
it.

* guix/ui.scm (display-generation): Add second argument to 'highlight'.
2022-02-14 15:52:36 +01:00
Ludovic Courtès 7ffcee1937
ui: 'with-paginated-output-port' gives access to the wrapped port.
* guix/ui.scm (pager-port-mapping): New variable.
(pager-wrapped-port): New procedure.
(call-with-paginated-output-port): Parameterize 'pager-port-mapping'.
2022-02-14 15:52:36 +01:00
jgart d25a4e49d7
guix: ui: Fix typo in docstring.
* guix/ui.scm (colorize-store-file-name)[docstring]: Fix typo.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2022-01-22 21:35:47 -05:00
Ludovic Courtès 54237556ba
ui: 'package->recutils' can split the "system:" line.
Previously, long system lines would not be split, which would confuse
'less', possibly leading it to hide the first line of the package
recutils record (the "name:" line).

* guix/ui.scm (package->recutils)[split-lines]: New procedure.
[dependencies->recutils]: Use it.
Use it for the "systems:" value.
2022-01-11 20:35:00 +01:00
Leo Famulari 806a4e986d
ui: It's 2022!
Happy new year!

* guix/ui.scm (show-version-and-exit): Change the year to 2022.
2022-01-01 02:02:44 -05:00
Ludovic Courtès 4d59596a1c
ui: 'load*' correctly reports 'read-error' in all cases.
Previously, 'read-error' exceptions other than "missing closing paren"
would not be reported; instead, we'd directly call (exit 1) without
printing anything.

Fixes <https://issues.guix.gnu.org/51463>.
Reported by Alice BRENON <alice.brenon@ens-lyon.fr>.

* guix/ui.scm (report-load-error): Report the error without re-throwing
upon 'read-error'.
* tests/guix-build.sh: Add test.
2021-11-07 23:10:41 +01:00
Tobias Geerinckx-Rice 8f45555781
ui: Use DISPLAY in SHOW-GUIX-HELP.
* guix/ui.scm (show-guix-help): Use DISPLAY where FORMAT isn't needed.
2021-10-31 00:57:07 +02:00
Tobias Geerinckx-Rice 943dd59beb
ui: Add top-level options to help text.
This also makes automated ‘guix --h<Tab>’ completion possible.

* guix/ui.scm (show-guix-help): Document that an OPTION's an option,
and all valid options.
2021-10-31 00:57:07 +02:00
Ludovic Courtès 6938d9f1c7
ui: Gracefully handle invalid Texinfo markup in package blurbs.
Previously 'guix search' & co. would crash when encountering invalid
Texinfo.

* guix/ui.scm (texi->plain-text*): New procedure.
(package-field-string, package->recutils): Use it.
2021-10-28 21:30:27 +02:00
Steve Sprang 423f5f867c
ui: Improve output appearance when listing generations.
* guix/ui.scm (display-profile-content-diff): Use pretty-print-table to format
output.
(display-profile-content): Likewise.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2021-07-15 16:11:47 -04:00
Ludovic Courtès ab37731a8d
ui: Have 'guix help' stat less.
This reduces the number of syscalls for:

  env -i $(type -P strace) -c $(type -P guix) help

from 4.3K to 2.2K, thereby reducing startup time.

Reported by Julien Lepiller.

* guix/ui.scm (run-guix-command): Move %FILE-PORT-NAME-CANONICALIZATION
to...
(run-guix): ... here.
2021-06-29 00:00:13 +02:00
Ludovic Courtès 5bcb4f8a58
ui, lint: Simplify exception handling in Guile 3 style.
* guix/lint.scm (check-derivation)[try]: Remove "catch #t" wrapping.
* guix/ui.scm (call-with-error-handling): Remove "catch 'system-error"
and move 'system-error handling to the &exception-with-kind-and-args
clause.
2021-06-01 23:26:07 +02:00
Ludovic Courtès 82d8ab01f5
maint: Require Guile 3.0.
* configure.ac: Require Guile 3.0.
* doc/guix.texi (Requirements): Adjust accordingly.
* gnu/packages/package-management.scm (guile2.2-guix): Remove.
* guix/lint.scm (exception-with-kind-and-args?): Remove 'cond-expand'.
* guix/scripts/deploy.scm (deploy-machine*): Likewise.
* guix/store.scm (call-with-store): Likewise.
* guix/swh.scm (http-get*, http-post*): Likewise.
* guix/ui.scm (without-compiler-optimizations, guard*)
(call-with-error-handling): Likewise.
2021-06-01 23:26:07 +02:00
Ludovic Courtès a0ad636167
ui: 'load*' compiles with '-O1'.
With this change, the wall-clock time of:

  guix system build --no-grafts -d gnu/system/install.scm

goes from 5.0s to 2.3s on Guile 3.0.5.

* guix/ui.scm (without-compiler-optimizations): New macro.
(load*): Use it.
2021-05-17 23:59:58 +02:00
Ludovic Courtès 4288806111
ui: Remove Guile 2.2.3 workaround.
This became dead code with commit
4f621a2b00.

* guix/ui.scm (load*): Remove Guile 2.2.3 workaround.
2021-05-17 23:59:58 +02:00
Maxim Cournoyer afec278417
ui: Suggest installing glibc-locales, not glibc-utf8-locales.
Users (both old and new) struggling with locale warnings is a recurrent theme;
part of it may be due to the glibc-utf8-locales package being misleading, as
it only includes a subset of the UTF-8 locales.  To prevent confusion, suggest
installing the glibc-locales package instead.

* guix/ui.scm (install-locale): Do not mention glibc-utf8-locales in the hint
message.  Use glibc-locales instead of glibc-utf8-locales in the provided
example.
2021-05-05 00:44:17 -04:00
Ludovic Courtès 524c9800af
diagnostics, ui: Adjust to 'read-error' and 'syntax-error' in Guile 3.0.6.
* guix/diagnostics.scm (source-properties->location): Add clause for
vectors.
* guix/ui.scm (report-load-error): Tweak 'read-error' handling for 3.0.6.
* tests/guix-package.sh: Relax regexp for the "unbound variable"
diagnostic check.
* tests/guix-system.sh: Adjust "missing closing paren" check for 3.0.6.
* tests/records.scm (location-alist): New procedure.
("define-record-type* & wrong field specifier")
("define-record-type* & wrong field specifier, identifier")
("define-record-type* & duplicate initializers"): Use it.
2021-04-29 01:22:04 +02:00
Ludovic Courtès b288d0e749
ui: Bug-report URL in '--help' can be translated.
* guix/ui.scm (show-bug-report-information): Add "/en" to the help URL
and pass it to 'G_'.
2021-02-24 23:44:10 +01:00
Brice Waegeneire 8a452e156e
ui: Fix typo in description.
* guix/ui.scm (switch-to-generation*): Fix typo in description.
2021-02-19 13:35:01 +01:00
zimoun f0a1a55c66
ui: Add hint for command typo.
* guix/ui.scm (command-hint): New variable
(run-guix-command): Use it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-02-03 12:41:29 +01:00
zimoun 95852b305b
ui: Look up extensions before built-in commands.
* guix/ui.scm (run-guix-command): Modify order so that extensions are allowed
to override default commands.

Co-authored-by: Ricardo Wurmus <rekado@elephly.net>
2021-01-28 15:07:55 +01:00
Simon Tournier a0f019b81f
ui: Fix order of match clauses.
Fixes <https://bugs.gnu.org/45709>.

This is a follow-up to commit cf289d7cfa.

* guix/ui.scm (run-guix-command): Match for #false first.

Signed-off-by: Ricardo Wurmus <rekado@elephly.net>
2021-01-07 18:10:58 +01:00
Ricardo Wurmus cf289d7cfa
Discover extensions via GUIX_EXTENSIONS_PATH.
* guix/scripts.scm (%command-categories): Add extension category.
* guix/ui.scm (source-file-command): Also parse extensions files.
(command-files): Accept an optional directory argument.
(extension-directories): New procedure.
(commands): Use it.
(show-guix-help): Hide empty categories.
(run-guix-command): Try loading an extension if there is no matching Guix
command.
2021-01-05 23:58:21 +01:00
Ludovic Courtès fa42774742
ui: It's 2021 now!
* guix/ui.scm (show-version-and-exit): Change year to 2021.
2021-01-04 23:54:16 +01:00
Tobias Geerinckx-Rice a81258c124
ui: Handle multiword and empty $PAGER values.
* guix/ui.scm (call-with-paginated-output-port): Empty PAGER values
disable paging.  Non-empty ones are split into command arguments.

Reported by Daniel Brooks <db48x@db48x.net>.
2020-12-05 16:47:59 +01:00
Ludovic Courtès 5842239a66
deploy: Let key-and-args exceptions through.
Fixes <https://bugs.gnu.org/44825>.
Reported by Christopher Lemmer Webber <cwebber@dustycloud.org>.

* guix/ui.scm (guard*): Export.
* guix/scripts/deploy.scm (deploy-machine*): Use 'guard*' instead of
'guard'.  Add '&exception-with-kind-and-args' case.
2020-11-26 23:39:15 +01:00
Ludovic Courtès 362529963e
ui: Use the right accessor when reporting '&gexp-input-error'.
* guix/ui.scm (call-with-error-handling): In the 'gexp-input-error?'
case, use 'gexp-error-invalid-input' as the accessor.
2020-11-10 14:40:20 +01:00
Ludovic Courtès db1b18c397
ui: Add missing format argument in 'warn-about-load-error'.
* guix/ui.scm (warn-about-load-error): Add missing argument to 'warning'.
2020-11-06 21:42:39 +01:00
Ludovic Courtès 5ef1508942
ui: Only suggest modules that export the unbound variable identifier.
Fixes <https://bugs.gnu.org/43498>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.

* guix/ui.scm (known-variable-definition): Check for variables in the
public interface of HEAD, not in HEAD itself.
* tests/guix-build.sh: Add test.
2020-10-15 18:50:22 +02:00
Ludovic Courtès dc749a0e91
ui: Use "guix install" in locale hint.
* guix/ui.scm (install-locale): Change "guix package -i" to "guix install".
2020-10-02 08:11:38 +02:00
Ludovic Courtès 7dc19c33fc
ui: "guix help" silently ignores EPIPE.
This avoids a backtrace when running "guix help | head" or similar.

* guix/ui.scm (run-guix): Wrap 'show-guix-help' calls in
'leave-on-EPIPE'.
2020-10-01 12:45:38 +02:00
Ludovic Courtès 846403ef62
ui: 'show-what-to-build' displays download estimate more prominently.
* guix/ui.scm (show-what-to-build): When VERBOSITY is 1, add a newline
before the "would/will be downloaded" line, and wrap that message in
'highlight'.
2020-09-14 15:42:56 +02:00
Maxim Cournoyer 140da556be
ui: Lexicographically sort transaction entries based on their package name.
* guix/ui.scm (show-manifest-transaction): Sort entries to be displayed in a
tabulated view.
2020-09-12 02:08:14 -04:00
Maxim Cournoyer 7d3eb5e6b7
ui: Refactor the package-strings helper in show-manifest-transaction.
* guix/ui.scm (show-manifest-transaction)[package-strings]: Add an
OLD-VERSIONS keyword parameter.  Absorb the code path previously found in the
upgrade-string.  Remove upgrade-string.
(show-manifest-transaction): Adjust to the above changes.
2020-09-12 02:08:14 -04:00
Ludovic Courtès 3794ce93be
scripts: Use 'define-command' and have 'guix help' use that.
This changes 'guix help' to print a short synopsis for each command and
to group commands by category.

* guix/scripts.scm (synopsis, category): New variables.
(define-command-categories, define-command): New macros.
(%command-categories): New variable.
* guix/ui.scm (<command>): New record type.
(source-file-command): New procedure.
(command-files): Return absolute file names.
(commands): Return a list of <command> records.
(show-guix-help)[display-commands, category-predicate]: New procedures.
Display commands grouped in three categories.
* guix/scripts/archive.scm (guix-archive): Use 'define-command'.
* guix/scripts/authenticate.scm (guix-authenticate): Likewise.
* guix/scripts/build.scm (guix-build): Likewise.
* guix/scripts/challenge.scm (guix-challenge): Likewise.
* guix/scripts/container.scm (guix-container): Likewise.
* guix/scripts/copy.scm (guix-copy): Likewise.
* guix/scripts/deploy.scm (guix-deploy): Likewise.
* guix/scripts/describe.scm (guix-describe): Likewise.
* guix/scripts/download.scm (guix-download): Likewise.
* guix/scripts/edit.scm (guix-edit): Likewise.
* guix/scripts/environment.scm (guix-environment): Likewise.
* guix/scripts/gc.scm (guix-gc): Likewise.
* guix/scripts/git.scm (guix-git): Likewise.
* guix/scripts/graph.scm (guix-graph): Likewise.
* guix/scripts/hash.scm (guix-hash): Likewise.
* guix/scripts/import.scm (guix-import): Likewise.
* guix/scripts/install.scm (guix-install): Likewise.
* guix/scripts/lint.scm (guix-lint): Likewise.
* guix/scripts/offload.scm (guix-offload): Likewise.
* guix/scripts/pack.scm (guix-pack): Likewise.
* guix/scripts/package.scm (guix-package): Likewise.
* guix/scripts/perform-download.scm (guix-perform-download): Likewise.
* guix/scripts/processes.scm (guix-processes): Likewise.
* guix/scripts/publish.scm (guix-publish): Likewise.
* guix/scripts/pull.scm (guix-pull): Likewise.
* guix/scripts/refresh.scm (guix-refresh): Likewise.
* guix/scripts/remove.scm (guix-remove): Likewise.
* guix/scripts/repl.scm (guix-repl): Likewise.
* guix/scripts/search.scm (guix-search): Likewise.
* guix/scripts/show.scm (guix-show): Likewise.
* guix/scripts/size.scm (guix-size): Likewise.
* guix/scripts/substitute.scm (guix-substitute): Likewise.
* guix/scripts/system.scm (guix-system): Likewise.
* guix/scripts/time-machine.scm (guix-time-machine): Likewise.
* guix/scripts/upgrade.scm (guix-upgrade): Likewise.
* guix/scripts/weather.scm (guix-weather): Likewise.
2020-09-10 12:27:24 +02:00
Ludovic Courtès 991fdb0d64
ui: '--help' output links to <https://guix.gnu.org/help/>.
* guix/ui.scm (show-bug-report-information): Link to
<https://guix.gnu.org/help/> instead of <https://www.gnu.org/gethelp/>.
The former is much more useful and includes links to GNU manuals.
2020-09-10 12:27:24 +02:00
Ludovic Courtès fe4e770fc1
ui: Attempt to fall back to "en_US.utf8" rather than "C".
* guix/ui.scm (install-locale): Add call to 'setlocale' in 'catch' handler.
2020-09-02 17:17:37 +02:00
Ludovic Courtès 05f3d34094
ui: Report key-and-arg exceptions correctly.
Fixes <https://bugs.gnu.org/42601>.
Reported by Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>.

Regression introduced in efe037fc5c
whereby errors like 'wrong-type-arg' would be improperly reported:

  guix environment: error: Wrong type argument in position ~A (expecting ~A): ~S

See also commit a07d5e558b.

* guix/ui.scm (call-with-error-handling): Move 'message-condition?'
clause after '&exception-with-kind-and-args' clause.
2020-08-05 22:28:28 +02:00
Ludovic Courtès a55d83b546
ui: Add #:verbosity to 'show-what-to-build'.
* guix/ui.scm (%default-verbosity): New variable.
(show-what-to-build): Add #:verbosity and honor it.
(build-notifier): Add #:verbosity and pass it to 'show-what-to-build'.
2020-08-03 17:17:41 +02:00
Ludovic Courtès 9296a2e511
processes: Allow 'less' to properly estimate line length.
Until now, the first few lines in the output of 'guix processes' could
disappear in 'less'.

* guix/ui.scm (call-with-paginated-output-port): Add #:less-options
parameter and honor it.
(with-paginated-output-port): Allow callers to pass #:less-options.
* guix/scripts/processes.scm (guix-processes): Pass #:less-options to
'with-paginated-output-port'.
2020-07-27 12:06:35 +02:00
Ludovic Courtès d51bfe242f
Use 'formatted-message' instead of '&message' where appropriate.
* gnu.scm (%try-use-modules): Use 'formatted-message' instead of
'&message'.
* gnu/machine/digital-ocean.scm (maybe-raise-unsupported-configuration-error):
Likewise.
* gnu/machine/ssh.scm (machine-check-file-system-availability): Likewise.
(machine-check-building-for-appropriate-system): Likewise.
(deploy-managed-host): Likewise.
(maybe-raise-unsupported-configuration-error): Likewise.
* gnu/packages.scm (search-patch): Likewise.
* gnu/services.scm (%service-with-default-value): Likewise.
(files->etc-directory): Likewise.
(fold-services): Likewise.
* gnu/system.scm (locale-name->definition*): Likewise.
* gnu/system/mapped-devices.scm (check-device-initrd-modules): Likewise.
(check-luks-device): Likewise.
* guix/channels.scm (latest-channel-instance): Likewise.
* guix/cve.scm (json->cve-items): Likewise.
* guix/git-authenticate.scm (commit-signing-key): Likewise.
(commit-authorized-keys): Likewise.
(authenticate-commit): Likewise.
(verify-introductory-commit): Likewise.
* guix/remote.scm (remote-pipe-for-gexp): Likewise.
* guix/scripts/graph.scm (assert-package): Likewise.
* guix/scripts/offload.scm (private-key-from-file*): Likewise.
* guix/ssh.scm (authenticate-server*): Likewise.
(open-ssh-session): Likewise.
(remote-inferior): Likewise.
* guix/ui.scm (matching-generations): Likewise.
* guix/upstream.scm (package-update): Likewise.
* tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"):
Catch 'formatted-message?'.
("authenticate-channel, wrong first commit signer"): Likewise.
* tests/lint.scm ("patches: not found"): Adjust message string.
* tests/packages.scm ("patch not found yields a run-time error"): Catch
'formatted-message?'.
* guix/lint.scm (check-patch-file-names): Handle 'formatted-message?'.
(check-derivation): Ditto.
2020-07-25 19:11:37 +02:00
Ludovic Courtès 252a1926bc
diagnostics: Add '&formatted-message'.
This allows 'gettext' to be called on the format string at the site
where the exception is caught (rather than the site where it's thrown).
It also allows for argument highlighting.

* guix/diagnostics.scm (&formatted-message): New condition type.
(check-format-string): New procedure.
(formatted-message): New macro.
* guix/ui.scm (report-load-error): Add clause for 'formatted-message?'.
(warn-about-load-error): Likewise.
(call-with-error-handling): Likewise.
(read/eval): Likewise.
2020-07-25 19:11:36 +02:00
Ludovic Courtès efe037fc5c
ui: Factorize '&message' handling.
* guix/ui.scm (call-with-error-handling): Factorize the three
'message-condition?' clauses into one.
2020-07-25 19:11:36 +02:00