337
|
1 py 3
|
|
2
|
|
3 Web 2.0
|
|
4 =======
|
|
5
|
|
6 .. image:: web-2-0-logos.gif
|
|
7 :height: 300 px
|
|
8
|
|
9 But first...
|
|
10 ============
|
|
11
|
|
12 .. image:: sargon.jpg
|
|
13 :height: 300 px
|
|
14
|
|
15 Sargon the Great founded the Akkadian Empire
|
|
16 in the twenty-third century BC.
|
|
17
|
|
18 In between
|
|
19 ==========
|
|
20
|
|
21 .. image:: apple.jpg
|
|
22 :height: 300 px
|
|
23
|
|
24 Unlike the Akkadian Empire, the CLI will never disappear.
|
|
25
|
|
26 line-oriented command interpreter
|
|
27 command-line interface
|
|
28 text user interface
|
|
29 terminal user interface
|
|
30 console
|
|
31 shell
|
|
32
|
|
33 Defining
|
|
34 ========
|
|
35
|
|
36 Prompt accepts free text input
|
|
37 Outputs lines of text
|
|
38 CLI environment persists
|
|
39
|
|
40 Examples
|
|
41 ========
|
|
42
|
|
43 Bash, Korn, zsh
|
|
44 Python shell
|
|
45 screen
|
|
46 Zork
|
|
47 ed
|
|
48 SQL clients: psql, SQL*\Plus, mysql...
|
|
49
|
|
50 != Command Line Utilities
|
|
51 =========================
|
|
52
|
|
53 Accept single set of arguments at
|
|
54 invocation, execute, terminate
|
|
55
|
|
56 dir
|
|
57 grep
|
|
58 ping
|
|
59
|
|
60 sys.argv
|
|
61 optparse
|
|
62
|
|
63 != Text User Interfaces
|
|
64 =======================
|
|
65
|
|
66 ("console")
|
|
67
|
|
68 Use entire (session) screen
|
|
69 Not line-by-line
|
|
70
|
|
71 .. image:: urwid.png
|
|
72 :height: 300px
|
|
73
|
|
74 curses
|
|
75 urwid
|
|
76
|
|
77
|
|
78 foo a b c ->
|
|
79 self.do_foo('a b c')
|
|
80 self.default('foo a b c')
|
|
81
|
|
82 pirate.py
|
|
83 =========
|
|
84
|
|
85 ::
|
|
86
|
|
87 from cmd import Cmd
|
|
88
|
|
89 class Pirate(Cmd):
|
|
90 pass
|
|
91
|
|
92 pirate = Pirate()
|
|
93 pirate.cmdloop()
|
|
94
|
|
95 history: cursor
|
|
96 ctrl-r
|
|
97 help
|
|
98
|