Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@oclif/table
Advanced tools
@oclif/table is a utility for formatting and displaying tables in command-line interfaces (CLIs) built with the oclif framework. It provides a simple way to present tabular data in a readable format.
Basic Table Rendering
This feature allows you to render a basic table with specified columns and data. The code sample demonstrates how to create a table with 'Name' and 'Age' columns using the @oclif/table package.
const { table } = require('@oclif/table');
const data = [
{ name: 'John Doe', age: 30 },
{ name: 'Jane Smith', age: 25 }
];
const columns = {
name: {
header: 'Name'
},
age: {
header: 'Age'
}
};
table(data, { columns });
Custom Column Formatting
This feature allows for custom formatting of table columns. The code sample shows how to format the 'Name' column to be uppercase and the 'Age' column to append 'years' to the age value.
const { table } = require('@oclif/table');
const data = [
{ name: 'John Doe', age: 30 },
{ name: 'Jane Smith', age: 25 }
];
const columns = {
name: {
header: 'Name',
get: row => row.name.toUpperCase()
},
age: {
header: 'Age',
get: row => `${row.age} years`
}
};
table(data, { columns });
Sorting Table Data
This feature allows you to sort table data by a specified column. The code sample demonstrates sorting the table by the 'Age' column.
const { table } = require('@oclif/table');
const data = [
{ name: 'John Doe', age: 30 },
{ name: 'Jane Smith', age: 25 }
];
const columns = {
name: {
header: 'Name'
},
age: {
header: 'Age'
}
};
table(data, { columns, sort: 'age' });
cli-table3 is a popular package for creating tables in the command line. It offers similar functionality to @oclif/table, such as custom column formatting and alignment. However, cli-table3 is more widely used outside of the oclif framework and provides more customization options for table styling.
The 'table' package is another alternative for rendering tables in the command line. It provides a flexible API for table creation and supports features like text wrapping and alignment. Compared to @oclif/table, it is more focused on general CLI applications rather than being tied to a specific framework like oclif.
Print tables to the terminal using ink
You can see examples of how to use it in the examples directory.
You can run any of these with the following:
tsx examples/basic.ts
See the contributing guide.
FAQs
Display table in terminal
The npm package @oclif/table receives a total of 246,990 weekly downloads. As such, @oclif/table popularity was classified as popular.
We found that @oclif/table demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.