1{-# LANGUAGE OverloadedStrings #-}
8import Prelude hiding (init)
9import qualified Data.List as List
10import qualified Text.PrettyPrint.ANSI.Leijen as P
11import Text.PrettyPrint.ANSI.Leijen ((<>))
12import Text.Read (readMaybe)
14import qualified Elm.Version as V
16import Terminal.Args.Helpers
19import qualified Develop
22import qualified Install
24import qualified Publish
50 ["Hi,","thank","you","for","trying","out"
52 ,P.green (P.text (V.toChars V.compiler)) <> "."
53 ,"I hope you like it!"
56 , P.black "-------------------------------------------------------------------------------"
57 , P.black "I highly recommend working through <https://guide.elm-lang.org> to get started."
58 , P.black "It teaches many important concepts, including how to use `elm` in the terminal."
59 , P.black "-------------------------------------------------------------------------------"
65 P.fillSep $ map P.text $ words $
66 "Be sure to ask on the Elm slack if you run into trouble! Folks are friendly and\
67 \ happy to help out. They hang out there because it is fun, so be kind to get the\
79 "Start an Elm project. It creates a starter elm.json file and\
80 \ provides a link explaining what to do from there."
83 "The `init` command helps start Elm projects:"
87 "It will ask permission to create an elm.json file, the one thing common\
88 \ to all Elm projects. It also provides a link explaining what to do from there."
90 Interface "init" (Common summary) details example noArgs noFlags Init.run
101 "Open up an interactive programming session. Type in Elm expressions\
102 \ like (2 + 2) or (String.length \"test\") and see if they equal four!"
105 "The `repl` command opens up an interactive programming session:"
109 "Start working through <https://guide.elm-lang.org> to learn how to use this!\
110 \ It has a whole chapter that uses the REPL for everything, so that is probably\
111 \ the quickest way to get started."
115 |-- flag "interpreter" interpreter "Path to a alternate JS interpreter, like node or nodejs."
116 |-- onOff "no-colors" "Turn off the colors in the REPL. This can help if you are having trouble reading the values. Some terminals use a custom color scheme that diverges significantly from the standard ANSI colors, so another path may be to pick a more standard color scheme."
118 Interface "repl" (Common summary) details example noArgs replFlags Repl.run
121interpreter :: Parser String
124 { _singular = "interpreter"
125 , _plural = "interpreters"
127 , _suggest = \_ -> return []
128 , _examples = \_ -> return ["node","nodejs"]
140 "Compile code with a click. It opens a file viewer in your browser, and\
141 \ when you click on an Elm file, it compiles and you see the result."
144 "The `reactor` command starts a local server on your computer:"
148 "After running that command, you would have a server at <http://localhost:8000>\
149 \ that helps with development. It shows your files like a file viewer. If you\
150 \ click on an Elm file, it will compile it for you! And you can just press\
151 \ the refresh button in the browser to recompile things."
155 |-- flag "port" port_ "The port of the server (default: 8000)"
157 Interface "reactor" (Common summary) details example noArgs reactorFlags Develop.run
165 , _parser = readMaybe
166 , _suggest = \_ -> return []
167 , _examples = \_ -> return ["3000","8000"]
179 "The `make` command compiles Elm code into JS or HTML:"
185 , P.indent 4 $ P.green "elm make src/Main.elm"
187 "This tries to compile an Elm file named src/Main.elm, putting the resulting\
188 \ JavaScript code in an elm.js file."
193 |-- onOff "debug" "Turn on the time-travelling debugger. It allows you to rewind and replay events. The events can be imported/exported into a file, which makes for very precise bug reports!"
194 |-- onOff "optimize" "Turn on optimizations to make code smaller and faster. For example, the compiler renames record fields to be as short as possible and unboxes values to reduce allocation."
195 |-- flag "output" Make.output "Specify the name of the resulting JS file. For example --output=assets/elm.js to generate the JS at assets/elm.js or --output=/dev/null to generate no output at all!"
196 |-- flag "report" Make.reportType "You can say --report=json to get error messages as JSON. This is only really useful if you are an editor plugin. Humans should avoid it!"
197 |-- flag "docs" Make.docsFile "Generate a JSON file of documentation for a package. Eventually it will be possible to preview docs with `reactor` because it is quite hard to deal with these JSON files directly."
199 Interface "make" Uncommon details example (zeroOrMore elmFile) makeFlags Make.run
210 "The `install` command fetches packages from <https://package.elm-lang.org> for\
211 \ use in your project:"
216 "For example, if you want to get packages for HTTP and JSON, you would say:"
217 , P.indent 4 $ P.green $ P.vcat $
218 [ "elm install elm/http"
219 , "elm install elm/json"
222 "Notice that you must say the AUTHOR name and PROJECT name! After running those\
223 \ commands, you could say `import Http` or `import Json.Decode` in your code."
225 "What if two projects use different versions of the same package? No problem!\
226 \ Each project is independent, so there cannot be conflicts like that!"
231 [ require0 Install.NoArgs
232 , require1 Install.Install package
235 Interface "install" Uncommon details example installArgs noFlags Install.run
246 "The `publish` command publishes your package on <https://package.elm-lang.org>\
247 \ so that anyone in the Elm community can use it."
252 "Think hard if you are ready to publish NEW packages though!"
254 "Part of what makes Elm great is the packages ecosystem. The fact that\
255 \ there is usually one option (usually very well done) makes it way\
256 \ easier to pick packages and become productive. So having a million\
257 \ packages would be a failure in Elm. We do not need twenty of\
258 \ everything, all coded in a single weekend."
260 "So as community members gain wisdom through experience, we want\
261 \ them to share that through thoughtful API design and excellent\
262 \ documentation. It is more about sharing ideas and insights than\
263 \ just sharing code! The first step may be asking for advice from\
264 \ people you respect, or in community forums. The second step may\
265 \ be using it at work to see if it is as nice as you think. Maybe\
266 \ it ends up as an experiment on GitHub only. Point is, try to be\
267 \ respectful of the community and package ecosystem!"
269 "Check out https://package.elm-lang.org/help/design-guidelines for guidance on how to create great packages!"
272 Interface "publish" Uncommon details example noArgs noFlags Publish.run
283 "The `bump` command figures out the next version number based on API changes:"
287 "Say you just published version 1.0.0, but then decided to remove a function.\
288 \ I will compare the published API to what you have locally, figure out that\
289 \ it is a MAJOR change, and bump your version number to 2.0.0. I do this with\
290 \ all packages, so there cannot be MAJOR changes hiding in PATCH releases in Elm!"
292 Interface "bump" Uncommon details example noArgs noFlags Bump.run
303 "The `diff` command detects API changes:"
308 "For example, to see what changed in the HTML package between\
309 \ versions 1.0.0 and 2.0.0, you can say:"
310 , P.indent 4 $ P.green $ "elm diff elm/html 1.0.0 2.0.0"
312 "Sometimes a MAJOR change is not actually very big, so\
313 \ this can help you plan your upgrade timelines."
318 [ require0 Diff.CodeVsLatest
319 , require1 Diff.CodeVsExactly version
320 , require2 Diff.LocalInquiry version version
321 , require3 Diff.GlobalInquiry package version version
324 Interface "diff" Uncommon details example diffArgs noFlags Diff.run
331stack :: [P.Doc] -> P.Doc
333 P.vcat $ List.intersperse "" docs
336reflow :: String -> P.Doc
338 P.fillSep $ map P.text $ words string
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list