Skip to content

Commit

Permalink
Merge pull request lqdev#5 from lamg/main
Browse files Browse the repository at this point in the history
Refactored project and features added
  • Loading branch information
jonas1ara authored Jul 9, 2024
2 parents 2039191 + caa1f7f commit 782ad36
Show file tree
Hide file tree
Showing 35 changed files with 1,232 additions and 263 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "8.0.0",
"commands": [
"paket"
]
}
}
}
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.fs]
indent_size = 2
end_of_line = lf
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:8.0

steps:
- uses: actions/checkout@v4

- name: Run tests
run: |
dotnet tool restore
dotnet paket restore
dotnet test
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
## Get latest from `dotnet new gitignore`

# dotenv files
.env

# User-specific files
*.rsuser
Expand Down Expand Up @@ -317,7 +320,7 @@ node_modules/
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
.paket/
paket-files/

# FAKE - F# Make
Expand Down Expand Up @@ -399,6 +402,7 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea

##
## Visual studio for Mac
Expand Down Expand Up @@ -475,3 +479,6 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

# Vim temporary swap files
*.swp
57 changes: 26 additions & 31 deletions src/fitch.fsproj → Cli/Cli.fsproj
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>

<LangVersion>preview</LangVersion>
<Version>1.2.0</Version>
<PackageId>fitch</PackageId>
<PackAsTool>true</PackAsTool>
<ToolCommandName>fitch</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/lqdev/fitch</RepositoryUrl>
<Description>Command line system information display utility for Linux systems built with .NET (F#).</Description>
</PropertyGroup>

<ItemGroup>
<Compile Include="Utils.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.45.0" />
</ItemGroup>

</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Version>1.2.0</Version>
<PackageId>fitch</PackageId>
<PackAsTool>true</PackAsTool>
<ToolCommandName>fitch</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/lqdev/fitch</RepositoryUrl>
<Description>Command line system information display utility for Linux systems built with .NET (F#).</Description>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lib\Lib.fsproj" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
4 changes: 4 additions & 0 deletions Cli/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
open System

DisplayInfo.displayInfo ()
Console.ResetColor()
1 change: 1 addition & 0 deletions Cli/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FSharp.Core
24 changes: 24 additions & 0 deletions Lib/Colorize.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Lib.Colorize

open Lib.Types

let color (colorCode: string) =
let reset = "\x1b[0m"

match colorCode with
| "0"
| "1"
| "2"
| "3"
| "4"
| "5"
| "6" -> sprintf "%s\x1b[3%sm" reset colorCode
| "7"
| "fg" -> sprintf "\x1b[37m%s" reset
| _ -> sprintf "\x1b[38;5;%sm" colorCode

let replaceColors (logo: string) (colors: string list) =
let xs = colors |> List.mapi (fun i c -> sprintf "${c%d}" (i + 1), color $"{c}")
xs |> List.fold (fun (acc: string) -> acc.Replace) logo

let colorize (l: DistroLogo) = replaceColors l.logo l.colors
35 changes: 35 additions & 0 deletions Lib/DisplayInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module DisplayInfo

open Lib
open Spectre.Console
open Spectre.Console.Rendering
open Lib.SystemInfo

let loadLogo (logo: string) =
NeofetchLogos.logoDictionary.TryGetValue logo
|> function
| true, l -> l
| false, _ -> NeofetchLogos.logoDictionary["unknown"]
|> Colorize.colorize
|> Text
:> IRenderable

let displayInfo () =
let info = systemInfo ()

let (rows: IRenderable seq) =
seq {
Text($"Distribution: {info.distroName}", Style(Color.HotPink))
Text($"Kernel: {info.kernelName}", Style(Color.HotPink))
Text($"Shell: {info.shell}", Style(Color.HotPink))
Text($"User: {info.user}", Style(Color.Yellow))
Text($"Hostname: {info.hostName}", Style(Color.Yellow))
Text($"Uptime: {info.upTime}", Style(Color.Blue))
Text($"Memory: {info.memInfo}", Style(Color.Blue))
Text($"CPU: {info.cpuModel}", Style(Color.Blue))
Text($"LocalIP: {info.localIp}", Style(Color.Green))
}
let logoPanel = loadLogo info.distroId
let textPanel = Rows rows :> IRenderable
let columns = Columns [textPanel; logoPanel]
AnsiConsole.Write columns
18 changes: 18 additions & 0 deletions Lib/Lib.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Types.fs" />
<Compile Include="Colorize.fs" />
<Compile Include="NeofetchLogos.fs" />
<Compile Include="SystemInfo.fs" />
<Compile Include="DisplayInfo.fs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Logos\*.txt" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
19 changes: 19 additions & 0 deletions Lib/Logos/arch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
${c1} -`
${c1} .o+`
${c1} `ooo/
${c1} `+oooo:
${c1} `+oooooo:
${c1} -+oooooo+:
${c1} `/:-:++oooo+:
${c1} `/++++/+++++++:
${c1} `/++++++++++++++:
${c1} `/+++o${c2}oooooooo${c1}oooo/`
${c2} ${c1}./${c2}ooosssso++osssssso${c1}+`
${c2} .oossssso-````/ossssss+`
${c2} -osssssso. :ssssssso.
${c2} :osssssss/ osssso+++.
${c2} /ossssssss/ +ssssooo/-
${c2} `/ossssso+/:- -:/+osssso+-
${c2} `+sso+:-` `.-/+oso:
${c2} `++:. `-/+/
${c2} .` `/
17 changes: 17 additions & 0 deletions Lib/Logos/debian.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
${c2} _,met$$$$$gg.
${c2} ,g$$$$$$$$$$$$$$$P.
${c2} ,g$$P" """Y$$.".
${c2} ,$$P' `$$$.
${c2}',$$P ,ggs. `$$b:
${c2}`d$$' ,$P"' ${c1}.${c2} $$$
${c2} $$P d$' ${c1},${c2} $$P
${c2} $$: $$. ${c1}-${c2} ,d$$'
${c2} $$; Y$b._ _,d$P'
${c2} Y$$. ${c1}`.${c2}`"Y$$$$P"'
${c2} `$$b ${c1}"-.__
${c2} `Y$$
${c2} `Y$$.
${c2} `$$b.
${c2} `Y$$b.
${c2} `"Y$b._
${c2} `"""
19 changes: 19 additions & 0 deletions Lib/Logos/fedora.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
${c1} .',;::::;,'.
${c1} .';:cccccccccccc:;,.
${c1} .;cccccccccccccccccccccc;.
${c1} .:cccccccccccccccccccccccccc:.
${c1} .;ccccccccccccc;${c2}.:dddl:.${c1};ccccccc;.
${c1} .:ccccccccccccc;${c2}OWMKOOXMWd${c1};ccccccc:.
${c1}.:ccccccccccccc;${c2}KMMc${c1};cc;${c2}xMMc${c1};ccccccc:.
${c1},cccccccccccccc;${c2}MMM.${c1};cc;${c2};WW:${c1};cccccccc,
${c1}:cccccccccccccc;${c2}MMM.${c1};cccccccccccccccc:
${c1}:ccccccc;${c2}oxOOOo${c1};${c2}MMM0OOk.${c1};cccccccccccc:
${c1}cccccc;${c2}0MMKxdd:${c1};${c2}MMMkddc.${c1};cccccccccccc;
${c1}ccccc;${c2}XM0'${c1};cccc;${c2}MMM.${c1};cccccccccccccccc'
${c1}ccccc;${c2}MMo${c1};ccccc;${c2}MMW.${c1};ccccccccccccccc;
${c1}ccccc;${c2}0MNc.${c1}ccc${c2}.xMMd${c1};ccccccccccccccc;
${c1}cccccc;${c2}dNMWXXXWM0:${c1};cccccccccccccc:,
${c1}cccccccc;${c2}.:odl:.${c1};cccccccccccccc:,.
${c1}:cccccccccccccccccccccccccccc:'.
${c1}.:cccccccccccccccccccccc:;,..
${c1} '::cccccccccccccc::;,.
17 changes: 17 additions & 0 deletions Lib/Logos/mac.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
${c1} c.'
${c1} ,xNMM.
${c1} .OMMMMo
${c1} lMM"
${c1} .;loddo:. .olloddol;.
${c1} cKMMMMMMMMMMNWMMMMMMMMMM0:
${c2} .KMMMMMMMMMMMMMMMMMMMMMMMWd.
${c2} XMMMMMMMMMMMMMMMMMMMMMMMX.
${c3};MMMMMMMMMMMMMMMMMMMMMMMM:
${c3}:MMMMMMMMMMMMMMMMMMMMMMMM:
${c4}.MMMMMMMMMMMMMMMMMMMMMMMMX.
${c4} kMMMMMMMMMMMMMMMMMMMMMMMMWd.
${c5} 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk
${c5} 'XMMMMMMMMMMMMMMMMMMMMMMMMK.
${c6} kMMMMMMMMMMMMMMMMMMMMMMd
${c6} ;KMMMMMMMWXXWMMMMMMMk.
${c6} "cooc*" "*coo'"
19 changes: 19 additions & 0 deletions Lib/Logos/mint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
${c2} ...-:::::-...
${c2} .-MMMMMMMMMMMMMMM-.
.-MMMM${c1}`..-:::::::-..`${c2}MMMM-.
.:MMMM${c1}.:MMMMMMMMMMMMMMM:.${c2}MMMM:.
-MMM${c1}-M---MMMMMMMMMMMMMMMMMMM.${c2}MMM-
`:MMM${c1}:MM` :MMMM:....::-...-MMMM:${c2}MMM:`
:MMM${c1}:MMM` :MM:` `` `` `:MMM:${c2}MMM:
.MMM${c1}.MMMM` :MM. -MM. .MM- `MMMM.${c2}MMM.
:MMM${c1}:MMMM` :MM. -MM- .MM: `MMMM-${c2}MMM:
:MMM${c1}:MMMM` :MM. -MM- .MM: `MMMM:${c2}MMM:
:MMM${c1}:MMMM` :MM. -MM- .MM: `MMMM-${c2}MMM:
.MMM${c1}.MMMM` :MM:--:MM:--:MM: `MMMM.${c2}MMM.
:MMM${c1}:MMM- `-MMMMMMMMMMMM-` -MMM-${c2}MMM:
:MMM${c1}:MMM:` `:MMM:${c2}MMM:
.MMM${c1}.MMMM:--------------:MMMM.${c2}MMM.
'-MMMM${c1}.-MMMMMMMMMMMMMMM-.${c2}MMMM-'
'.-MMMM${c1}``--:::::--``${c2}MMMM-.'
${c2} '-MMMMMMMMMMMMM-'
${c2} ``-:::::-``
20 changes: 20 additions & 0 deletions Lib/Logos/nixos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
${c1} ▗▄▄▄ ${c2}▗▄▄▄▄ ▄▄▄▖
${c1} ▜███▙ ${c2}▜███▙ ▟███▛
${c1} ▜███▙ ${c2}▜███▙▟███▛
${c1} ▜███▙ ${c2}▜██████▛
${c1} ▟█████████████████▙ ${c2}▜████▛ ${c1}▟▙
${c1} ▟███████████████████▙ ${c2}▜███▙ ${c1}▟██▙
${c2} ▄▄▄▄▖ ▜███▙ ${c1}▟███▛
${c2} ▟███▛ ▜██▛ ${c1}▟███▛
${c2} ▟███▛ ▜▛ ${c1}▟███▛
${c2}▟███████████▛ ${c1}▟██████████▙
${c2}▜██████████▛ ${c1}▟███████████▛
${c2} ▟███▛ ${c1}▟▙ ▟███▛
${c2} ▟███▛ ${c1}▟██▙ ▟███▛
${c2} ▟███▛ ${c1}▜███▙ ▝▀▀▀▀
${c2} ▜██▛ ${c1}▜███▙ ${c2}▜██████████████████▛
${c2} ▜▛ ${c1}▟████▙ ${c2}▜████████████████▛
${c1} ▟██████▙ ${c2}▜███▙
${c1} ▟███▛▜███▙ ${c2}▜███▙
${c1} ▟███▛ ▜███▙ ${c2}▜███▙
${c1} ▝▀▀▀ ▀▀▀▀▘ ${c2}▀▀▀▘
20 changes: 20 additions & 0 deletions Lib/Logos/ubuntu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
${c1} .-/+oossssoo+\-.
${c1} ´:+ssssssssssssssssss+:`
${c1} -+ssssssssssssssssssyyssss+-
${c1} .ossssssssssssssssss${c2}dMMMNy${c1}sssso.
${c1} /sssssssssss${c2}hdmmNNmmyNMMMMh${c1}ssssss\
${c1} +sssssssss${c2}hm${c1}yd${c2}MMMMMMMNddddy${c1}ssssssss+
${c1} /ssssssss${c2}hNMMM${c1}yh${c2}hyyyyhmNMMMNh${c1}ssssssss\
${c1}.ssssssss${c2}dMMMNh${c1}ssssssssss${c2}hNMMMd${c1}ssssssss.
${c1}+ssss${c2}hhhyNMMNy${c1}ssssssssssss${c2}yNMMMy${c1}sssssss+
${c1}oss${c2}yNMMMNyMMh${c1}ssssssssssssss${c2}hmmmh${c1}ssssssso
${c1}oss${c2}yNMMMNyMMh${c1}sssssssssssssshmmmh${c1}ssssssso
${c1}+ssss${c2}hhhyNMMNy${c1}ssssssssssss${c2}yNMMMy${c1}sssssss+
${c1}.ssssssss${c2}dMMMNh${c1}ssssssssss${c2}hNMMMd${c1}ssssssss.
${c1} \ssssssss${c2}hNMMM${c1}yh${c2}hyyyyhdNMMMNh${c1}ssssssss/
${c1} +sssssssss${c2}dm${c1}yd${c2}MMMMMMMMddddy${c1}ssssssss+
${c1} \sssssssssss${c2}hdmNNNNmyNMMMMh${c1}ssssss/
${c1} .ossssssssssssssssss${c2}dMMMNy${c1}sssso.
${c1} -+sssssssssssssssss${c2}yyy${c1}ssss+-
${c1} `:+ssssssssssssssssss+:`
${c1} .-\+oossssoo+/-.
12 changes: 12 additions & 0 deletions Lib/Logos/unknown.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
${c2} #####
${c2} #######
${c2} ##${c1}O${c2}#${c1}O${c2}##
${c2} #${c3}#####${c2}#
${c2} ##${c1}##${c3}###${c1}##${c2}##
${c2} #${c1}##########${c2}##
${c2} #${c1}############${c2}##
${c2} #${c1}############${c2}###
${c3} ##${c2}#${c1}###########${c2}##${c3}#
${c3}######${c2}#${c1}#######${c2}#${c3}######
${c3}#######${c2}#${c1}#####${c2}#${c3}#######
${c3} #####${c2}#######${c3}#####
Loading

0 comments on commit 782ad36

Please sign in to comment.