Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ project read `miso.yml` in the current directory (not in a parent).
| `miso upgrade [VERSION]` | install the latest release (or `VERSION`) in place |
| `miso uninstall [--yes]` | remove miso's files: in `$MISO_HOME` (packages, caches; the caches only when the folder holds nothing else) and the tool where `install.sh` put it (not one installed with nix). It shows what it removes and asks first; without a terminal it needs `--yes`. It lists the lines of your shell files that add miso to `PATH` (it does not edit them) |
| `miso version` | the version of miso and of MicroHs (also `--version`) |
| `miso help` | the commands (also `--help`, or no command) |
| `miso help` | the commands (also `--help`, `-h`, or no command) |
| `miso mhs ARGS` / `miso mcabal ARGS` | the MicroHs compiler, and MicroCabal |

Output is colored on a terminal; set `NO_COLOR=1` to turn that off.
Expand Down
7 changes: 5 additions & 2 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,17 +474,20 @@ miso version
miso --version
```

Prints `miso VERSION (MicroHs VERSION)`.
Prints `miso VERSION (MicroHs VERSION)`. On a terminal, `miso --version`
shows the logo, a bowl of ramen, above it.

### miso help

```
miso help
miso --help
miso -h
miso
```

Prints the commands. An unknown command prints them too, and fails.
Prints the commands, under the logo when the output is a terminal. An
unknown command prints them too (without the logo), and fails.

`miso COMMAND --help` (or `-h`) prints the usage of that command, and does
not run it. For `run` and `test`, which give their arguments to the
Expand Down
84 changes: 84 additions & 0 deletions src/Miso/CLI/Logo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
-- | The miso logo: a bowl of ramen (🍜), in ASCII, shown by miso, miso
-- help (-h, --help) and miso --version when the output is a terminal.
module Miso.CLI.Logo (printLogo) where

import Control.Monad (when)
import Data.List (groupBy)
import Data.Function (on)

import Miso.CLI.Color

-- | Print the logo, if stdout is a terminal (so $(miso --version) is one line).
printLogo :: IO ()
printLogo = do
tty <- isTerminal
when tty $ do
ls <- mapM line (zip art paint)
putStrLn (unlines ls)
where
line (a, p) = concat <$> mapM run (groupBy ((==) `on` snd) (zip a (p ++ repeat ' ')))
run cs = colored 1 (colors (snd (head cs))) (map fst cs)
colors k =
case k of
's' -> [Dim] -- steam
'c' -> [Bold] -- chopsticks
'n' -> [Yellow] -- noodles
't' -> [Magenta] -- naruto and egg
'b' -> [Red] -- the bowl
_ -> []

-- The art, generated, with paint: the color of each character
-- (s steam, c chopsticks, n noodles, t toppings, b bowl).
art :: [String]
art =
[ " / /"
, " ( ( ( / /"
, " ) ) ) / /"
, " ( ( ( / /"
, " ) ) ) / /"
, " ( ( ( / /"
, " ) ) ) / /"
, " ( ( ( / /"
, " / /"
, " _..--'''''''''''''''''''''''''/''/'''''''''''--.._"
, " .-'' ~~~~ ~~~~~ ~~~~~~ ~~~~~ /~~/~~ ~~~~~ ~~~~ ''-."
, " .' ~~~~ ~~~~ .-\"\"-. ~~~~~ ~~~ .--. ~~~~~ ~~~~ ~~~ '."
, " ( ~~~~~ ~~~ ( @ ) ~~~ ~~~~ ( () ) ~~~~ ~~~~~~ ~~ )"
, " |'-..~~~~~~ '-..-' ~~~~~~~~~~~ '--' ~~~~~~ ~~~~~~ __..-'|"
, " | ''''-----..............................-----'''' |"
, " \\ /"
, " \\ /"
, " '. .'"
, " '. .'"
, " '-._ _.-'"
, " '-..__ __..-'"
, " ''---..................---''"
, " |______________________|"
]

paint :: [String]
paint =
[ " c c"
, " s s s c c"
, " s s s c c"
, " s s s c c"
, " s s s c c"
, " s s s c c"
, " s s s c c"
, " s s s c c"
, " c c"
, " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcbbcbbbbbbbbbbbbbbbb"
, " bbbb nnnn nnnnn nnnnnn nnnnn cnncnn nnnnn nnnn bbbb"
, " bb nnnn nnnn tttttt nnnnn nnn tttt nnnnn nnnn nnn bb"
, " b nnnnn nnn t t t nnn nnnn t tt t nnnn nnnnnn nn b"
, " bbbbbnnnnnn tttttt nnnnnnnnnnn tttt nnnnnn nnnnnn bbbbbbb"
, " b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb b"
, " b b"
, " b b"
, " bb bb"
, " bb bb"
, " bbbb bbbb"
, " bbbbbb bbbbbb"
, " bbbbbbbbbbbbbbbbbbbbbbbbbbbb"
, " bbbbbbbbbbbbbbbbbbbbbbbb"
]
10 changes: 6 additions & 4 deletions src/Miso/CLI/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Miso.CLI.Config
import Miso.CLI.Deps
import Miso.CLI.Docs (docs)
import Miso.CLI.Doctor (doctor)
import Miso.CLI.Logo (printLogo)
import Miso.CLI.Serve (dev, serve, watch)
import Miso.CLI.Templates (licenseText, templateNames, templates)
import Miso.CLI.Util
Expand Down Expand Up @@ -103,10 +104,11 @@ main' = do
["upgrade"] -> upgrade Nothing
["upgrade", v] -> upgrade (Just v)
["version"] -> printVersion
["--version"] -> printVersion
["help"] -> usage
["--help"] -> usage
[] -> usage
["--version"] -> printLogo >> printVersion
["help"] -> printLogo >> usage
["--help"] -> printLogo >> usage
["-h"] -> printLogo >> usage
[] -> printLogo >> usage
_ -> usage >> failWith ("unknown command: miso " ++ unwords args)

-- | The commands, in the sections of miso help: the command as typed,
Expand Down
Loading