first commit

This commit is contained in:
♥ Minnie ♥ 2024-09-14 04:28:20 +08:00
commit a63c0c6d0a
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
8 changed files with 201 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.direnv/
.envrc
dist-newstyle/

3
.stylish-haskell.yaml Normal file
View file

@ -0,0 +1,3 @@
steps:
- imports:
align: file

5
CHANGELOG.md Normal file
View file

@ -0,0 +1,5 @@
# Revision history for teleios
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.

20
LICENSE Normal file
View file

@ -0,0 +1,20 @@
Copyright (c) 2024 sajenim
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

63
app/Main.hs Normal file
View file

@ -0,0 +1,63 @@
{-# LANGUAGE MultiWayIf #-}
import Data.List.Split (splitOn)
import System.Directory (setCurrentDirectory)
import System.Exit (exitSuccess)
import System.IO
import System.Process (callCommand)
prompt :: IO ()
prompt = do
input <- moshReadLine promptStringOne
moshExecute input
prompt
moshReadLine :: String -> IO String
moshReadLine ps1 = do
putStr ps1
hFlush stdout
getLine
moshExecute :: String -> IO ()
moshExecute input = do
if
| command == "exit" -> exitSuccess
| command == "help" -> moshHelp
| command == "cd" -> changeDirectory path
| otherwise -> callCommand input
where
command = head (splitOn " " input)
path = last (splitOn " " input)
changeDirectory :: FilePath -> IO ()
changeDirectory path = do
setCurrentDirectory path
moshHelp :: IO ()
moshHelp = do
putStrLn "---------------------"
putStrLn "MoSH -- Monadic Shell"
putStrLn "Author: sajenim"
putStrLn "---------------------"
putStrLn "Type program names and arguments, and hit enter."
putStrLn ""
putStrLn "The following are built in:"
putStr (unlines (prepend " " builtinCommands))
putStrLn ""
putStrLn "Use the man command for information on other programs"
builtinCommands :: [String]
builtinCommands = [ "cd"
, "help"
, "exit"
]
promptStringOne :: String
promptStringOne = "> "
prepend :: String -> [String] -> [String]
prepend s = map (s ++)
main :: IO ()
main = do
prompt

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1723221148,
"narHash": "sha256-7pjpeQlZUNQ4eeVntytU3jkw9dFK3k1Htgk2iuXjaD8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "154bcb95ad51bc257c2ce4043a725de6ca700ef6",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

18
flake.nix Normal file
View file

@ -0,0 +1,18 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [ghc cabal-install haskell-language-server];
};
});
}

28
mosh.cabal Normal file
View file

@ -0,0 +1,28 @@
cabal-version: 3.0
name: mosh
version: 0.1.0.0
-- synopsis:
-- description:
license: MIT
license-file: LICENSE
author: sajenim
maintainer: its.jassy@pm.me
-- copyright:
build-type: Simple
extra-doc-files: CHANGELOG.md
-- extra-source-files:
common warnings
ghc-options: -Wall
executable teleios
import: warnings
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.18.2.1,
process,
directory,
split
hs-source-dirs: app
default-language: Haskell2010