jasonivey / mmotd Goto Github PK
View Code? Open in Web Editor NEWmmotd is a C++ implementation of the elements contained in the Linux application motd, message of the day.
License: MIT License
mmotd is a C++ implementation of the elements contained in the Linux application motd, message of the day.
License: MIT License
At some point when adding, moving and renaming files the habit of adding the vim
control block started being left out.
On C++ source files this should just be:
// vim: awa:sts=4:ts=4:sw=4:et:cin:fdm=manual:tw=120:ft=cpp
On C++ header files this should be:
// vim: awa:sts=4:ts=4:sw=4:et:cin:fdm=manual:tw=120:ft=cpp
#pragma once
Threads are no longer leaking exceptions. But now the errors are simply being ignored. Add library or logic (i.e. current_exception
, make_exception_ptr
and rethrow_exception
) to transport the exceptions being thrown in threads to be caught and handled in main
.
When logging into Ubuntu
a fimiliar and useful set of information is the following:
1 update can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
And the following:
*** System restart required ***
This information can be easily gathered from reading a couple files.
This essentially means to plug all the pieces together (some of them by hand) until we have a working mmotd
binary which works as described.
Most of the information providers are complete. The cpu temperature and fan speeds are one which have yet to be implemented.
Linux is going to be a supported platform so the quicker there is a base implementation and CI runners the further it will push the project along.
The output template is much more complicated than it needs to be. The average user will not ever use the feature unless they are highly, highly motivated to add/remove or otherwise customize their output.
The first thing to simplify the format of the output template is to remove fields which have turned out to serve no purpose. The row_index
is the most obvious and the most aggravating.
char
char8_t
char16_t
char32_t
wchar_t
Now that bit_cast
is standard all instances of reinterpret_cast
should be either removed or converted. Also, just listened to a cppcon web replay. Turns out modifying a const_cast
variable is undefined behavior
Currently the application can output the default config
and the default template
. Unit tests need to be added to validate that the most current data is always validated.
This involves two steps:
doxygen
or standardese
to begin documenting the project.The AppConfig
contains values for each information provider. These values need to be plugged into those information providers and disable them when the AppConfig
reports them as disabled
.
When the table
component was first added it needed to be fort::utf8_table
since there are non-ascii color escape sequences embedded within the strings. But when the results were validated on a Linux
machine the table.to_string()
method caused the application to crash (segfault
).
Not having the time to properly debug the problem the table definition was switched to fort::char_table
on Linux
platforms and it appeared to solve the issue.
I'm not sure if the crash was due to the ssh
session I was using or something special about the Linux terminal (i.e. TERM != xterm-256color
). That should be the initial point of investigation.
After learning more of 3rd party libraries it seems there is a much better way of solving the problem than with git submodules
.
CMake now has the FetchContent
feature which allows you to specify an external project to be pulled and configured during the initial configure stage.
I think this will:
/external
directoryThe README.md
has not been updated in some time. Now that there is a working version of the project the README.md
should include a demo gif
. In addition, now that the continuous integration build has been enabled the a badge should be added to show the pass
/fail
status.
All of the exception
catching location should be expecting std::exception
and/or boost::exception
. The boost::exception
is currently setup to carry function
, file
, line
and stack trace
.
This should be refactored to carry a SourceLocation
object and stack trace
.
Then all boost::exception
catch locations should extract this information.
In addition, the MakeExceptionMessage
and all three overloads are making the exception objects/API unnecessarily difficult to grok/understand.
Lastly, when an exception
is thrown I believe the stack trace
is generated 3 or 4 times. It should be once!
I believe the usage of the C++ standard template library is going to be massively affected by the introduction to range-v3
library and all the capabilities they provide. I'd like to start using that as soon as possible for no other reason than personal gain. :)
All objects which query for computer information are derived from the InformationProvider
abstract class.
They must all override the FindInformation()
function to query and set the computer information. The class calls FindInformation()
via the LookupInformation()
method. Both of these methods were returning bool
but since the method is being called via threads the result is always ignored.
These two methods should be changed to return void
.
The better-enums looks to be an interesting project. I'm not sure if its exactly what I need but once I get the initial phase of code complete working I will be adding support for specifying external components. The better-enums
project could be very helpful in that situation.
When there were 3 network interfaces detected (network card, bridge 1, bridge 2) the call to Frame::RemoveEmptyRows
.
I am the first to admit that I am not a front-end UI developer. For this reason, I'd like to take the most reusable parts of this application and intelligently package it together (with as few dependencies as possible) into a shared library (.so
/.dylib
/.dll
) and the necessary public headers.
When monitor
and resolution
are queried on an Ubuntu Linux 20.04 virtual machine they are displayed as the following:
GPU: VMware SVGA II Adapter
Monitor:
Resolution:
...
Is this what should be displayed or should it be [unknown]
or should the two labels not be displayed at all?
In my fervor to get everything up and running I forgot to make sure my submodules were properly pointing towards a release tag. As I've been removing the submodules I noticed that if I'm not using the HEAD version of CLI11 I can't compile. It's a pretty minor issue but I'd rather fix it by waiting for the next release from CLI11.
The plog
logging library has been great. This issue is only to explore the possibility of either finding a small wrapper package around fmt::format
or creating my own wrapper package around fmt::format
.
In addition I would also like to add component discovery. (i.e. "ip address discovery" vs "prepare information for output")
When there is no -t
or --template
option specified on the command line set the default to the built in default template (i.e. the template which would be written out when a user specifies the create_template
sub command.
This should be a simple refactor to change MakeOutputTemplate
take two parameters or add an overload. The current method just takes a file name path. But this change would make it so it could take a string instead and load the output template
from the string
or the file name
.
See: common/results/include/output_template.h
There are a number of additional information, if when provided, can ensure the validity of certain information providers.
The following items need to be added as either required
or non-required
options to the config file:
The fmt::format
library can be setup to check at compile time that it's args are all valid. Unfortunately, to do this you either need to wrap the format
string in FMT_STRING
or define FMT_ENFORCE_COMPILE_STRING
on the command line.
There is also options to compile the format string before runtime via the FMT_COMPILE
macro.
I'm currently flying with my own style which is half my own style and half python
style. Time to commit to an automated style.
Review usages of std::regex
and determine if the use case is warranted for the heavy duty tool of a regular expression. If a regular expression is really called for then look for ways of either compiling it once for the binary or other ways of optimizing the usage.
Recently the --color <WHEN>
command line option was added. Taking the default usage from most every other command line application it accepts never
, auto
and always
.
The never
and always
were implemented when the option was added. The auto
needs to query the terminal (isatty
) for what the stdout
file is pointing towards.
jsoncpp
can be replaced with boost::property_tree
. I believe property_tree
is a viable header-only solution.
I haven't thought of how to boost::log
with something else. But there are plenty of logging libraries. I just need to find a fast and small one (preferably header-only).
Then there is boost::beast
and boost::asio
for http
and https
networking. There should be something else available. I don't really feel like falling back on cUrl
again.
The way all the classes are dynamically registered pre-main style there is no-one actually referencing the classes directly. This makes the linker just wipe out their object files making their code disappear before they are able to register. To fix this the classes need to add an extern
global that the main
or test
app can reference.
Andrei Alexandrescu and Petru Marginean proposed the concept of a scope guard using the RAII concept as the basis.
They have also proposed adding it to the standard, although I believe it has been pushed off for C++20. Luckily, Ricardo Abreu has done the work of wrapping the simplest version of the library in a GitHub repository with "The Unlicense".
I've added quite a few submodules. Not really happy about it but don't see another way around doing https
requests, logging
, fmt
, json
etc. without relying on submodules.
I'm just not sure whether I checked out a released version of each submodule when I added them.
Refactor the mish-mash of namespaces used within the project.
// root namespace in the project
namespace mmotd;
// root namespace in the project
namespace mmotd::core;
// common shared source for mmotd
namespace mmotd::information;
A refactor to simplify the output template is to simplify the column structure. Right now, the columns are defined in the config->columns
array. Turns out, this is more configurable than needed. It was designed this way so you could have columnA
, columnC
and columnE
with empty columns between each. But at this point this seems to add more confusion than is necessary to the output template definition.
Both the boost::json
library (introduced in version: 1_75
) and library boost::describe
(introduced in version: 1_77
). Using these libraries instead of standalone projects, cloned from GitHub
and then built as part of the build would be significantly more efficient.
A couple shell commands should help to identify which which shell binary is being used and then call each of these with the various --version
syntax will provide the version numbers.
Create two more working Output Template json
files within the config
directory.
One which will produce output (almost) identical to what neofetch
produces.
The second json
file should be able to produce output (almost) identical to what screenFetch
produces.
This will be done in hopes that it makes the transition to mmod
even easier and provide an opportunity to dig into the Output Template json
file
Currently common/results/src/template_column_items.cpp
contains the method:
std::optional<std::uint32_t> FromString(std::string_view str, int base = 10);
This should be templated on the return type
and and input type
and moved into common/include/algorithm.h
. With this refactor more code can reuse this algorithm easily. Specifically, common/include/chrono_io.h
has a need for it within the method:
inline std::optional<std::size_t> get_current_hour()
Look into various components. I believe spdlog
already supports fmt
out of the box.
I'm going to attempt using the "Mediator" pattern which has the huge benefit that no other code knows about any other code. In addition, as the need rises (and there isn't a reason to believe otherwise), it will be relatively simple to add multithreading to the mediator. Since all other aspects of the app are running in complete seclusion they shouldn't know anything about it.
Package up results of release builds (binaries
, configs
, templates
, includes
).
Depending on the template passed to the app the output should change what and how the information is displayed (i.e. number of columns, highlighting information, etc.).
Windows 10 is going to be a supported platform so the quicker there is a base implementation and CI runners the further it will push the project along.
This has been left long enough. The project needs a continuous integration on pull request merge (or on any branch that receives a commit).
To begin with the first CI build should be done for macOS Catalina for the sake of simplicity. But there will be another issue where we add build support for Linux and Windows along with adding CI builds for their OS's as well.
There are two tasks involved in this issue:
There are a couple instances where a value does not exist. Right now the output looks like:
CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
CPU Cores: 6 (little endian)
CPU Temperature:
GPU: VMware SVGA II Adapter
In this case a virtual machine doesn't have access to the host to query the CPU temperature. But there are a few other instances as well. This needs to be switched into an option? maybe and if that option is enabled then these entire lines should be left out of the output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.