Commit Graph

26 Commits (5d796b567819ce91740fcdea7cbafecbda65d8f3)

Author SHA1 Message Date
TBK 5d796b5678 use SPDX-License-Identifier in source files 2020-05-07 10:45:42 +03:00
Antoine Fontaine e8522411c1 lower min-width to 25 columns
Some screen size are quite small. For example, the default phosh
terminal is less than 50 character wide on Pinephone. This lowers the minimum
loading bar size to 25 characters.

For comparison, 25 character wide is just as wide as "apk add firefox
linux-lts" without the quotes.

Here's a bad picture to illustrate the result
gitlab.alpine.org/uploads/48c20f746fbf685b62b6bd73585ecbf2/pinephone-phosh.png
2020-03-21 17:41:49 +02:00
Sören Tempel a6039e38a4 Humanize size output of `apk info`
This commits adds a function for receiving the closet byte unit and the
size in that unit for a given size_t. The function doesn't return a
string since dynamic memory allocation (or a static buffer) would be
required to implement this properly.

Discussion: It might be useful to add a command line flag for disabling
this behaviour in order to retain compatibility with the previous apk
info output format.
2020-01-05 23:26:50 +02:00
Timo Teräs 59271f8c13 print: don't print spurious newlines 2018-11-02 15:40:45 +02:00
William Pitcock 17f8c2edec print: oh dear, i have reworked the progress bar again
- rework the progress bar a little bit, basically removing the [ and ] to give a more
  modern aesthetic.

- if utf-8 locale is enabled, use unicode codepoint 0x2588 instead of # to give the
  progress bar a nicer look.

- if APK_PROGRESS_CHAR environment variable is defined, use the character defined there
  for the progress bar.
2017-06-01 05:25:56 +00:00
Timo Teräs 027df02dc2 print: handle mixing stdout and stderr printing
Fixes regression from commit 5ba27c90 which caused stdio
buffering issues now that output is split to stderr/stdout.

See also commit 51737872 for some of the history.

Fixes #7107
2017-04-26 09:34:32 +03:00
William Pitcock a841d6b259 print: don't shadow log() 2017-04-24 23:53:26 +00:00
Shiz 5ba27c9000 print: print warnings and errors to stderr 2017-04-24 22:42:29 +00:00
Avi Halachmi (:avih) 515f31eb52 progress: shorten bar to prevent newlines on some terminals
On some (probably buggy) terminals, printing up to the rightmost column
may end up with the terminal issueing a newline (probably due to putting
the cursor at the next char -> new line).

Some other progress bars avoid it by not reaching the rightmost column.

Shorten the bar width from term-width - 7 to -8 (the 7 are "xxx% []").
2017-03-29 08:14:39 +03:00
Timo Teräs fd98e9c718 modifications for the previous commit in error message handling
forgot to --amend my changes
2015-04-24 09:32:22 +03:00
Alex Dowad 74dc8e232f print.c: provide more detailed error messages if retrieving a package fails
fetch_maperror() translates error codes returned by libfetch to our error
codes. Handle those in apk_error_str(), returning error messages which
advise the user of the most likely fix.

A custom error code, EAPKSTALEINDEX, has been added for cases where
retrieving a package fails due to a HTTP error 404 or similar.

[TimoT: add also EAPKBADURL, as well as organize a bit better where the
EAPKSTALEINDEX is generated]
2015-04-22 20:08:16 +03:00
Natanael Copa 1f8b793471 print: flush on apk_log
Makes it more useful whith pipes.
2013-12-05 10:58:23 +01:00
Timo Teräs 5173787218 print: use stdout instead of stderr for logging and progress
stdout is the proper place for it. this also fixes the progress
bar in musl, which seems to not support using line buffering for
stderr.
2013-10-11 14:52:34 +03:00
Natanael Copa adc5b0b161 print: move progress bar update logic to apk_print_progress
- let the apk_print functions deal with the forced print itself. We
  avoid that the callbacks need to deal with the force flag. We can
  also get rid of the APK_PRINT_PROGRESS_* defines.

- let the reader of --progress-fd decide how often things are updated
  rather than having a fixed granularity off 1/100 (percent)

- avoid detect screen size and percent/bar calculations in case the
  --no-progress was given

- track satistics for both the ascii bar and percent info and update bar
  only if either percent or bar changes. This makes the bar go smoother
  when width is wider than 100 chars and it makes the percent counter
  go smooth when screen width is less thann 100 chars. It also
  simplifies the callbacks as they no longer need to deal with update
  granularity.
2013-06-19 10:00:31 +00:00
Natanael Copa 0e9d67aea8 print: percent arg for process_fd is integer
With commit 0a13141889 the percent
variable became an integer instead of size_t. We fix the format
modifier accordingly.
2013-06-19 08:07:37 +02:00
Timo Teräs 0a13141889 print: move progress printing to common functions 2013-06-17 16:47:49 +03:00
Timo Teräs 9d10037807 db: refactor repository file construction
Fixes also 'fetch' applet to prefer copying/linking to files from
cache if possible.
2013-06-17 14:38:27 +03:00
Timo Teräs e51232e710 errors: rewrite the logic how errors are reported
Instead of the dependency oriented logic, switch to print them
for each package or name needed. Might give a bit more readable
errors now. There's still few corner cases that proper error is
not output, which are cought by the test cases.
2013-06-13 18:22:00 +03:00
Timo Teräs dd923ed065 print: minimum screen width of 50 2012-02-10 15:20:57 +02:00
Timo Teräs 1817b0a3c3 all: update copyright year statement 2011-09-13 11:53:01 +03:00
Timo Teräs bfd53b59d2 print: minor cleanup to indented writer 2011-09-09 20:06:10 +03:00
Timo Teräs 6b24f3c399 apk: improve indented printing
* fixup the help messages to align up properly
 * refresh screen width on SIGWINCH
2011-07-22 12:08:35 +03:00
Timo Teräs 972bec3210 various: use 'atoms' for certain package field and misc fixes
- implement a hash table for commonly shared fields such as
   license, version and architecture
 - use macroes to print blobs or pkgname-pkgver strings
 - fix some old cruft
2010-12-14 19:51:16 +02:00
Timo Teräs d92df52079 io: enhance istream/bstreams with pipe to forked child
* prunes the child pid to avoid zombies
 * handles the errors so e.g. file-not-found is reported properly
2010-12-09 10:47:09 +02:00
Natanael Copa 11925542d8 print: clean up after copy-paste 2010-06-11 07:09:25 +00:00
Natanael Copa 3ec82a5a42 First steps for libapk 2010-06-11 07:02:18 +00:00