steps:
- name: Install additional packages
- run: apt-get update && apt-get install -y --no-install-recommends acl-dev autoconf automake bzip2 docbook-xsl e2fslibs-dev g++ gettext libboost-dev libboost-system-dev libboost-test-dev libboost-thread-dev libbtrfs-dev libdbus-1-dev libjson-c-dev libmount-dev libpam-dev libtool libxml2-dev libz-dev locales-all make xsltproc
+ run: apt-get update && apt-get install -y --no-install-recommends acl-dev autoconf automake bzip2 docbook-xsl e2fslibs-dev g++ gettext libboost-dev libboost-system-dev libboost-test-dev libboost-thread-dev libbtrfs-dev libdbus-1-dev libjson-c-dev libmount-dev libpam-dev libtool libxml2-dev libz-dev locales-all make ncurses-dev xsltproc
- name: List installed packages
run: apt list --installed | sort
steps:
- name: Install additional packages
- run: dnf -y install acl autoconf automake boost-devel btrfs-progs-devel bzip2 dbus-devel diffutils docbook-style-xsl e2fsprogs-devel gcc-c++ gettext glibc-langpack-de glibc-langpack-en json-c-devel libacl-devel libmount-devel libtool libxml2-devel libxslt make pam-devel
+ run: dnf -y install acl autoconf automake boost-devel btrfs-progs-devel bzip2 dbus-devel diffutils docbook-style-xsl e2fsprogs-devel gcc-c++ gettext glibc-langpack-de glibc-langpack-en json-c-devel libacl-devel libmount-devel libtool libxml2-devel libxslt make ncurses-devel pam-devel
- name: List installed packages
run: rpm -qa | sort
steps:
- name: Install additional packages
- run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends acl-dev autoconf automake bzip2 docbook-xsl e2fslibs-dev g++ gettext language-pack-de language-pack-en libboost-dev libboost-system-dev libboost-test-dev libboost-thread-dev libbtrfs-dev libdbus-1-dev libjson-c-dev libmount-dev libpam-dev libtool libxml2-dev libz-dev make xsltproc
+ run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends acl-dev autoconf automake bzip2 docbook-xsl e2fslibs-dev g++ gettext language-pack-de language-pack-en libboost-dev libboost-system-dev libboost-test-dev libboost-thread-dev libbtrfs-dev libdbus-1-dev libjson-c-dev libmount-dev libpam-dev libtool libxml2-dev libz-dev make ncurses-dev xsltproc
- name: List installed packages
run: apt list --installed | sort
+ _("\t--utc\t\t\t\tDisplay dates and times in UTC.") + '\n'
+ _("\t--iso\t\t\t\tDisplay dates and times in ISO format.") + '\n'
+ _("\t--table-style, -t <style>\tTable style (integer).") + '\n'
+ + _("\t--abbreviate\t\t\tAllow to abbreviate table columns.") + '\n'
+ _("\t--machine-readable <format>\tSet a machine-readable output format (csv, json).") + '\n'
+ _("\t--csvout\t\t\tSet CSV output format.") + '\n'
+ _("\t--jsonout\t\t\tSet JSON output format.") + '\n'
Option("utc", no_argument),
Option("iso", no_argument),
Option("table-style", required_argument, 't'),
+ Option("abbreviate", no_argument),
Option("machine-readable", required_argument),
Option("csvout", no_argument),
Option("jsonout", no_argument),
_version = opts.has_option("version");
_help = opts.has_option("help");
_table_style = table_style_value(opts);
+ _abbreviate = opts.has_option("abbreviate");
_output_format = output_format_value(opts);
_separator = separator_value(opts);
_config = config_value(opts);
bool version() const { return _version; }
bool help() const { return _help; }
TableStyle table_style() const { return _table_style; }
+ bool abbreviate() const { return _abbreviate; }
OutputFormat output_format() const { return _output_format; }
string separator() const { return _separator; }
string config() const { return _config; }
bool _version;
bool _help;
TableStyle _table_style;
+ bool _abbreviate;
OutputFormat _output_format;
string _separator;
string _config;
continue;
formatter.header().push_back(header_for(list_mode, column));
+ formatter.abbrev().push_back(global_options.abbreviate() &&
+ column == Column::DESCRIPTION);
}
for (const ProxySnapshot& snapshot : output_helper.snapshots)
CsvFormatter.cc CsvFormatter.h \
JsonFormatter.cc JsonFormatter.h
-
-libutils_la_LIBADD = ../../snapper/libsnapper.la
+libutils_la_LIBADD = ../../snapper/libsnapper.la -ltinfo
, _max_width(1, 0)
, _width(0)
, _style (Ascii)
- , _screen_width(get_screen_width())
+ , _screen_width(snapper::get_screen_width())
, _margin(0)
, _force_break_after(-1)
, _do_wrap(false)
updateColWidths (tr);
}
-void Table::allowAbbrev(unsigned column) {
- if (column >= _abbrev_col.size()) {
- _abbrev_col.reserve(column + 1);
- _abbrev_col.insert(_abbrev_col.end(), column - _abbrev_col.size() + 1, false);
- }
- _abbrev_col[column] = true;
+
+void
+Table::set_abbrev(const vector<bool>& abbrev)
+{
+ _abbrev_col = abbrev;
}
+
void Table::updateColWidths (const TableRow& tr) {
// how much columns the separators add to the width of the table
int sepwidth = _style == none ? 2 : 3;
void set_style(TableStyle st);
void wrap(int force_break_after = -1);
- void allowAbbrev(unsigned column);
+ void set_abbrev(const vector<bool>& abbrev);
void margin(unsigned margin);
Table ();
table.dumpTo (stream);
return stream;
}
-// Local Variables:
-// c-basic-offset: 2
-// End:
+
#endif
table_header.add(column.first, column.second);
table.setHeader(table_header);
+ table.set_abbrev(table_formatter._abbrev);
for (const vector<string>& row : table_formatter._rows)
{
TableFormatter& operator=(const TableFormatter&) = delete;
vector<pair<string, TableAlign>>& header() { return _header; }
+ vector<bool>& abbrev() { return _abbrev; }
vector<vector<string>>& rows() { return _rows; }
friend ostream& operator<<(ostream& stream, const TableFormatter& table_formatter);
const TableStyle style;
vector<pair<string, TableAlign>> _header;
+ vector<bool> _abbrev;
vector<vector<string>> _rows;
};
* Miscellaneous console utilities.
*/
+
+#include <stdlib.h>
#include <unistd.h>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
+#include <term.h>
-using namespace std;
-unsigned get_screen_width()
+namespace snapper
{
- if (!::isatty(STDOUT_FILENO))
- return -1; // no clipping
- int width = 80;
- const char *cols_env = getenv("COLUMNS");
- if (cols_env)
- width = ::atoi (cols_env);
+ unsigned
+ get_screen_width_pure()
+ {
+ if (!isatty(STDOUT_FILENO))
+ return -1; // no clipping
+
+ int width = 0;
+
+ const char* cols_env = getenv("COLUMNS");
+ if (cols_env)
+ {
+ width = atoi(cols_env);
+ }
+ else
+ {
+ // use terminfo from ncurses
+ setupterm(NULL, STDOUT_FILENO, NULL);
+ width = tigetnum("cols");
+
+ /*
+ // use readline
+ rl_initialize();
+ rl_get_screen_size(NULL, &width);
+ */
+ }
+
+ // safe default
+ if (width <= 0)
+ width = 80;
+
+ return width;
+ }
+
+
+ unsigned
+ get_screen_width()
+ {
+ static unsigned width = get_screen_width_pure();
- // safe default
- if (!width)
- width = 80;
+ return width;
+ }
- return width;
}
* Miscellaneous console utilities.
*/
-#ifndef CONSOLE_H_
-#define CONSOLE_H_
-
-/**
- * Reads COLUMNS environment variable or gets the screen width from readline,
- * in that order. Falls back to 80 if all that fails.
- *
- * \NOTE In case stdout is not connected to a terminal max. unsigned
- * is returned. This should prevent clipping when output is redirected.
- */
-unsigned get_screen_width();
+#ifndef SNAPPER_CONSOLE_H
+#define SNAPPER_CONSOLE_H
+
+
+namespace snapper
+{
+
+ /**
+ * Reads COLUMNS environment variable or gets the screen width from terminfo
+ * or readline, in that order. Falls back to 80 if all that fails.
+ *
+ * \NOTE In case stdout is not connected to a terminal max. unsigned
+ * is returned. This should prevent clipping when output is redirected.
+ */
+ unsigned get_screen_width();
+
+}
+
-#endif /* CONSOLE_H_ */
+#endif
+snapper (0.8.15) stable; urgency=low
+
+ * Updated to version 0.8.15
+
+ -- Arvin Schnell <aschnell@suse.com> THu, 17 Dec 2020 10:22:04 +0000
+
snapper (0.8.14) stable; urgency=low
* Updated to version 0.8.14
Binary: snapper
Maintainer: Arvin Schnell <aschnell@suse.com>
Architecture: any
-Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, locales-all
+Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, locales-all, ncurses-dev
#
# The 'Files' line is generated during 'make package':
# Files:
Binary: snapper
Maintainer: Arvin Schnell <aschnell@suse.com>
Architecture: any
-Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, locales-all
+Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, locales-all, ncurses-dev
#
# The 'Files' line is generated during 'make package':
# Files:
Binary: snapper
Maintainer: Arvin Schnell <aschnell@suse.com>
Architecture: any
-Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, language-pack-en, language-pack-de
+Build-Depends: debhelper (>= 4.1.16), acl-dev, dbus, g++, libboost-dev, libboost-thread-dev, libboost-system-dev, libboost-test-dev, libxml2-dev, libz-dev, libdbus-1-dev, libjson-c-dev, libpam-dev, xsltproc, docbook-xsl, language-pack-en, language-pack-de, ncurses-dev
#
# The 'Files' line is generated during 'make package':
# Files:
<para>Specifies table style. Table style is identified by an integer number.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--abbreviate</option></term>
+ <listitem>
+ <para>Try to abbreviate texts in some columns so that tables fit the width of the screen.</para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--machine-readable <replaceable>format</replaceable></option></term>
<listitem>
+-------------------------------------------------------------------
+Thu Dec 17 12:20:59 CET 2020 - aschnell@suse.com
+
+- added option to abbreviate columns in table (see
+ gh#openSUSE/snapper#268)
+- version 0.8.15
+
-------------------------------------------------------------------
Fri Dec 04 10:05:05 CET 2020 - aschnell@suse.com
BuildRequires: libtool
BuildRequires: libxml2-devel
BuildRequires: e2fsprogs-devel
+BuildRequires: ncurses-devel
%if 0%{?suse_version} > 1230
BuildRequires: libbtrfs-devel
%endif