├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Godeps ├── Godeps.json ├── Readme └── _workspace │ ├── .gitignore │ └── src │ ├── code.google.com │ └── p │ │ ├── gcfg │ │ ├── LICENSE │ │ ├── README │ │ ├── doc.go │ │ ├── example_test.go │ │ ├── go1_0.go │ │ ├── go1_2.go │ │ ├── issues_test.go │ │ ├── read.go │ │ ├── read_test.go │ │ ├── scanner │ │ │ ├── errors.go │ │ │ ├── example_test.go │ │ │ ├── scanner.go │ │ │ └── scanner_test.go │ │ ├── set.go │ │ ├── testdata │ │ │ ├── gcfg_test.gcfg │ │ │ └── gcfg_unicode_test.gcfg │ │ ├── token │ │ │ ├── position.go │ │ │ ├── position_test.go │ │ │ ├── serialize.go │ │ │ ├── serialize_test.go │ │ │ └── token.go │ │ └── types │ │ │ ├── bool.go │ │ │ ├── doc.go │ │ │ ├── enum.go │ │ │ ├── enum_test.go │ │ │ ├── int.go │ │ │ ├── int_test.go │ │ │ ├── scan.go │ │ │ └── scan_test.go │ │ └── go.crypto │ │ └── ssh │ │ └── terminal │ │ ├── terminal.go │ │ ├── terminal_test.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ └── util_windows.go │ ├── github.com │ ├── creack │ │ └── termios │ │ │ └── raw │ │ │ ├── raw.go │ │ │ ├── raw_test.go │ │ │ ├── termios_32.go │ │ │ ├── termios_64.go │ │ │ ├── tioc_bsd.go │ │ │ └── tioc_linux.go │ ├── docopt │ │ └── docopt-go │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── docopt.go │ │ │ ├── docopt_test.go │ │ │ ├── example_test.go │ │ │ ├── examples │ │ │ ├── arguments │ │ │ │ └── arguments_example.go │ │ │ ├── calculator │ │ │ │ └── calculator_example.go │ │ │ ├── config_file │ │ │ │ └── config_file_example.go │ │ │ ├── counted │ │ │ │ └── counted_example.go │ │ │ ├── git │ │ │ │ ├── branch │ │ │ │ │ └── git_branch.go │ │ │ │ ├── checkout │ │ │ │ │ └── git_checkout.go │ │ │ │ ├── clone │ │ │ │ │ └── git_clone.go │ │ │ │ ├── git.go │ │ │ │ ├── push │ │ │ │ │ └── git_push.go │ │ │ │ └── remote │ │ │ │ │ └── git_remote.go │ │ │ ├── naval_fate │ │ │ │ └── naval_fate.go │ │ │ ├── odd_even │ │ │ │ └── odd_even_example.go │ │ │ ├── options │ │ │ │ └── options_example.go │ │ │ ├── options_shortcut │ │ │ │ └── options_shortcut_example.go │ │ │ ├── quick │ │ │ │ └── quick_example.go │ │ │ └── type_assert │ │ │ │ └── type_assert_example.go │ │ │ ├── test_golang.docopt │ │ │ └── testcases.docopt │ └── kr │ │ └── pty │ │ ├── .gitignore │ │ ├── License │ │ ├── README.md │ │ ├── doc.go │ │ ├── ioctl.go │ │ ├── ioctl_bsd.go │ │ ├── ioctl_linux.go │ │ ├── mktypes.bash │ │ ├── pty_darwin.go │ │ ├── pty_freebsd.go │ │ ├── pty_linux.go │ │ ├── pty_unsupported.go │ │ ├── run.go │ │ ├── types.go │ │ ├── types_freebsd.go │ │ ├── util.go │ │ ├── ztypes_386.go │ │ ├── ztypes_amd64.go │ │ ├── ztypes_arm.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ └── ztypes_freebsd_arm.go │ └── golang.org │ └── x │ ├── net │ └── html │ │ ├── atom │ │ ├── atom.go │ │ ├── atom_test.go │ │ ├── gen.go │ │ ├── table.go │ │ └── table_test.go │ │ ├── charset │ │ ├── charset.go │ │ ├── charset_test.go │ │ ├── gen.go │ │ ├── table.go │ │ └── testdata │ │ │ ├── HTTP-charset.html │ │ │ ├── HTTP-vs-UTF-8-BOM.html │ │ │ ├── HTTP-vs-meta-charset.html │ │ │ ├── HTTP-vs-meta-content.html │ │ │ ├── No-encoding-declaration.html │ │ │ ├── README │ │ │ ├── UTF-16BE-BOM.html │ │ │ ├── UTF-16LE-BOM.html │ │ │ ├── UTF-8-BOM-vs-meta-charset.html │ │ │ ├── UTF-8-BOM-vs-meta-content.html │ │ │ ├── meta-charset-attribute.html │ │ │ └── meta-content-attribute.html │ │ ├── const.go │ │ ├── doc.go │ │ ├── doctype.go │ │ ├── entity.go │ │ ├── entity_test.go │ │ ├── escape.go │ │ ├── escape_test.go │ │ ├── example_test.go │ │ ├── foreign.go │ │ ├── node.go │ │ ├── node_test.go │ │ ├── parse.go │ │ ├── parse_test.go │ │ ├── render.go │ │ ├── render_test.go │ │ ├── testdata │ │ ├── go1.html │ │ └── webkit │ │ │ ├── README │ │ │ ├── adoption01.dat │ │ │ ├── adoption02.dat │ │ │ ├── comments01.dat │ │ │ ├── doctype01.dat │ │ │ ├── entities01.dat │ │ │ ├── entities02.dat │ │ │ ├── html5test-com.dat │ │ │ ├── inbody01.dat │ │ │ ├── isindex.dat │ │ │ ├── pending-spec-changes-plain-text-unsafe.dat │ │ │ ├── pending-spec-changes.dat │ │ │ ├── plain-text-unsafe.dat │ │ │ ├── scriptdata01.dat │ │ │ ├── scripted │ │ │ ├── adoption01.dat │ │ │ └── webkit01.dat │ │ │ ├── tables01.dat │ │ │ ├── tests1.dat │ │ │ ├── tests10.dat │ │ │ ├── tests11.dat │ │ │ ├── tests12.dat │ │ │ ├── tests14.dat │ │ │ ├── tests15.dat │ │ │ ├── tests16.dat │ │ │ ├── tests17.dat │ │ │ ├── tests18.dat │ │ │ ├── tests19.dat │ │ │ ├── tests2.dat │ │ │ ├── tests20.dat │ │ │ ├── tests21.dat │ │ │ ├── tests22.dat │ │ │ ├── tests23.dat │ │ │ ├── tests24.dat │ │ │ ├── tests25.dat │ │ │ ├── tests26.dat │ │ │ ├── tests3.dat │ │ │ ├── tests4.dat │ │ │ ├── tests5.dat │ │ │ ├── tests6.dat │ │ │ ├── tests7.dat │ │ │ ├── tests8.dat │ │ │ ├── tests9.dat │ │ │ ├── tests_innerHTML_1.dat │ │ │ ├── tricky01.dat │ │ │ ├── webkit01.dat │ │ │ └── webkit02.dat │ │ ├── token.go │ │ └── token_test.go │ └── text │ ├── encoding │ ├── charmap │ │ ├── charmap.go │ │ ├── charmap_test.go │ │ ├── maketables.go │ │ └── tables.go │ ├── encoding.go │ ├── encoding_test.go │ ├── example_test.go │ ├── htmlindex │ │ ├── gen.go │ │ ├── htmlindex.go │ │ ├── htmlindex_test.go │ │ ├── map.go │ │ └── tables.go │ ├── ianaindex │ │ ├── example_test.go │ │ └── ianaindex.go │ ├── internal │ │ ├── identifier │ │ │ ├── gen.go │ │ │ ├── identifier.go │ │ │ └── mib.go │ │ └── internal.go │ ├── japanese │ │ ├── all.go │ │ ├── all_test.go │ │ ├── eucjp.go │ │ ├── iso2022jp.go │ │ ├── maketables.go │ │ ├── shiftjis.go │ │ └── tables.go │ ├── korean │ │ ├── all_test.go │ │ ├── euckr.go │ │ ├── maketables.go │ │ └── tables.go │ ├── simplifiedchinese │ │ ├── all.go │ │ ├── all_test.go │ │ ├── gbk.go │ │ ├── hzgb2312.go │ │ ├── maketables.go │ │ └── tables.go │ ├── testdata │ │ ├── candide-gb18030.txt │ │ ├── candide-utf-16le.txt │ │ ├── candide-utf-8.txt │ │ ├── candide-windows-1252.txt │ │ ├── rashomon-euc-jp.txt │ │ ├── rashomon-iso-2022-jp.txt │ │ ├── rashomon-shift-jis.txt │ │ ├── rashomon-utf-8.txt │ │ ├── sunzi-bingfa-gb-levels-1-and-2-hz-gb2312.txt │ │ ├── sunzi-bingfa-gb-levels-1-and-2-utf-8.txt │ │ ├── sunzi-bingfa-simplified-gbk.txt │ │ ├── sunzi-bingfa-simplified-utf-8.txt │ │ ├── sunzi-bingfa-traditional-big5.txt │ │ ├── sunzi-bingfa-traditional-utf-8.txt │ │ ├── unsu-joh-eun-nal-euc-kr.txt │ │ └── unsu-joh-eun-nal-utf-8.txt │ ├── traditionalchinese │ │ ├── all_test.go │ │ ├── big5.go │ │ ├── maketables.go │ │ └── tables.go │ └── unicode │ │ ├── override.go │ │ ├── unicode.go │ │ └── unicode_test.go │ ├── internal │ └── utf8internal │ │ └── utf8internal.go │ ├── runes │ ├── cond.go │ ├── cond_test.go │ ├── example_test.go │ ├── runes.go │ └── runes_test.go │ └── transform │ ├── examples_test.go │ ├── transform.go │ └── transform_test.go ├── LICENSE ├── Makefile ├── README.md ├── Vagrantfile ├── api ├── api.go └── http.go ├── asciicast ├── asciicast.go ├── frame.go ├── frame_test.go ├── player.go ├── recorder.go └── stream.go ├── commands ├── auth.go ├── play.go ├── rec.go ├── rec_test.go └── upload.go ├── doc └── asciicast-v1.md ├── install ├── main.go ├── man └── asciinema.1 ├── ptyx └── size.go ├── terminal ├── terminal.go └── terminal_test.go └── util ├── cfg.go ├── cfg_test.go ├── copy.go ├── echo.go ├── fdset_darwin.go ├── fdset_freebsd.go ├── fdset_freebsd_amd64.go ├── fdset_linux.go ├── fdset_linux_amd64.go ├── locale.go ├── locale_test.go ├── nonblank.go ├── readline.go ├── select.go ├── select_linux.go ├── spinner.go └── uuid.go /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | /dist 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - 1.6 9 | - tip 10 | 11 | script: make travis 12 | 13 | notifications: 14 | irc: 15 | channels: 16 | - "chat.freenode.net#asciinema" 17 | use_notice: true 18 | skip_join: true 19 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/asciinema/asciinema", 3 | "GoVersion": "go1.4.2", 4 | "Deps": [ 5 | { 6 | "ImportPath": "code.google.com/p/gcfg", 7 | "Rev": "c2d3050044d05357eaf6c3547249ba57c5e235cb" 8 | }, 9 | { 10 | "ImportPath": "code.google.com/p/go.crypto/ssh/terminal", 11 | "Comment": "null-213", 12 | "Rev": "aa2644fe4aa50e3b38d75187b4799b1f0c9ddcef" 13 | }, 14 | { 15 | "ImportPath": "github.com/creack/termios/raw", 16 | "Rev": "d60649a6c40aa68303e3d69e0423a1e7aedf4bbd" 17 | }, 18 | { 19 | "ImportPath": "github.com/docopt/docopt-go", 20 | "Comment": "0.6.1-1-gc5dac53", 21 | "Rev": "c5dac536301992c0371c6115d998fb62944bfad3" 22 | }, 23 | { 24 | "ImportPath": "github.com/kr/pty", 25 | "Comment": "release.r56-19-g67e2db2", 26 | "Rev": "67e2db24c831afa6c64fc17b4a143390674365ef" 27 | }, 28 | { 29 | "ImportPath": "golang.org/x/net/html", 30 | "Rev": "1d9fd3b8333e891c0e7353e1adcfe8a612573033" 31 | }, 32 | { 33 | "ImportPath": "golang.org/x/text/encoding", 34 | "Rev": "07b9a78963006a15c538ec5175243979025fa7a8" 35 | }, 36 | { 37 | "ImportPath": "golang.org/x/text/internal/utf8internal", 38 | "Rev": "07b9a78963006a15c538ec5175243979025fa7a8" 39 | }, 40 | { 41 | "ImportPath": "golang.org/x/text/runes", 42 | "Rev": "07b9a78963006a15c538ec5175243979025fa7a8" 43 | }, 44 | { 45 | "ImportPath": "golang.org/x/text/transform", 46 | "Rev": "07b9a78963006a15c538ec5175243979025fa7a8" 47 | } 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Péter Surányi. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | ---------------------------------------------------------------------- 27 | Portions of gcfg's source code have been derived from Go, and are 28 | covered by the following license: 29 | ---------------------------------------------------------------------- 30 | 31 | Copyright (c) 2009 The Go Authors. All rights reserved. 32 | 33 | Redistribution and use in source and binary forms, with or without 34 | modification, are permitted provided that the following conditions are 35 | met: 36 | 37 | * Redistributions of source code must retain the above copyright 38 | notice, this list of conditions and the following disclaimer. 39 | * Redistributions in binary form must reproduce the above 40 | copyright notice, this list of conditions and the following disclaimer 41 | in the documentation and/or other materials provided with the 42 | distribution. 43 | * Neither the name of Google Inc. nor the names of its 44 | contributors may be used to endorse or promote products derived from 45 | this software without specific prior written permission. 46 | 47 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 48 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 49 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 50 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 51 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 52 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 53 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 57 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/README: -------------------------------------------------------------------------------- 1 | Gcfg reads INI-style configuration files into Go structs; 2 | supports user-defined types and subsections. 3 | 4 | Project page: https://code.google.com/p/gcfg 5 | Package docs: http://godoc.org/code.google.com/p/gcfg 6 | 7 | My other projects: https://speter.net 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/example_test.go: -------------------------------------------------------------------------------- 1 | package gcfg_test 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | import "github.com/asciinema/asciinema/Godeps/_workspace/src/code.google.com/p/gcfg" 9 | 10 | func ExampleReadStringInto() { 11 | cfgStr := `; Comment line 12 | [section] 13 | name=value # comment` 14 | cfg := struct { 15 | Section struct { 16 | Name string 17 | } 18 | }{} 19 | err := gcfg.ReadStringInto(&cfg, cfgStr) 20 | if err != nil { 21 | log.Fatalf("Failed to parse gcfg data: %s", err) 22 | } 23 | fmt.Println(cfg.Section.Name) 24 | // Output: value 25 | } 26 | 27 | func ExampleReadStringInto_bool() { 28 | cfgStr := `; Comment line 29 | [section] 30 | switch=on` 31 | cfg := struct { 32 | Section struct { 33 | Switch bool 34 | } 35 | }{} 36 | err := gcfg.ReadStringInto(&cfg, cfgStr) 37 | if err != nil { 38 | log.Fatalf("Failed to parse gcfg data: %s", err) 39 | } 40 | fmt.Println(cfg.Section.Switch) 41 | // Output: true 42 | } 43 | 44 | func ExampleReadStringInto_hyphens() { 45 | cfgStr := `; Comment line 46 | [section-name] 47 | variable-name=value # comment` 48 | cfg := struct { 49 | Section_Name struct { 50 | Variable_Name string 51 | } 52 | }{} 53 | err := gcfg.ReadStringInto(&cfg, cfgStr) 54 | if err != nil { 55 | log.Fatalf("Failed to parse gcfg data: %s", err) 56 | } 57 | fmt.Println(cfg.Section_Name.Variable_Name) 58 | // Output: value 59 | } 60 | 61 | func ExampleReadStringInto_tags() { 62 | cfgStr := `; Comment line 63 | [section] 64 | var-name=value # comment` 65 | cfg := struct { 66 | Section struct { 67 | FieldName string `gcfg:"var-name"` 68 | } 69 | }{} 70 | err := gcfg.ReadStringInto(&cfg, cfgStr) 71 | if err != nil { 72 | log.Fatalf("Failed to parse gcfg data: %s", err) 73 | } 74 | fmt.Println(cfg.Section.FieldName) 75 | // Output: value 76 | } 77 | 78 | func ExampleReadStringInto_subsections() { 79 | cfgStr := `; Comment line 80 | [profile "A"] 81 | color = white 82 | 83 | [profile "B"] 84 | color = black 85 | ` 86 | cfg := struct { 87 | Profile map[string]*struct { 88 | Color string 89 | } 90 | }{} 91 | err := gcfg.ReadStringInto(&cfg, cfgStr) 92 | if err != nil { 93 | log.Fatalf("Failed to parse gcfg data: %s", err) 94 | } 95 | fmt.Printf("%s %s\n", cfg.Profile["A"].Color, cfg.Profile["B"].Color) 96 | // Output: white black 97 | } 98 | 99 | func ExampleReadStringInto_multivalue() { 100 | cfgStr := `; Comment line 101 | [section] 102 | multi=value1 103 | multi=value2` 104 | cfg := struct { 105 | Section struct { 106 | Multi []string 107 | } 108 | }{} 109 | err := gcfg.ReadStringInto(&cfg, cfgStr) 110 | if err != nil { 111 | log.Fatalf("Failed to parse gcfg data: %s", err) 112 | } 113 | fmt.Println(cfg.Section.Multi) 114 | // Output: [value1 value2] 115 | } 116 | 117 | func ExampleReadStringInto_unicode() { 118 | cfgStr := `; Comment line 119 | [甲] 120 | 乙=丙 # comment` 121 | cfg := struct { 122 | X甲 struct { 123 | X乙 string 124 | } 125 | }{} 126 | err := gcfg.ReadStringInto(&cfg, cfgStr) 127 | if err != nil { 128 | log.Fatalf("Failed to parse gcfg data: %s", err) 129 | } 130 | fmt.Println(cfg.X甲.X乙) 131 | // Output: 丙 132 | } 133 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/go1_0.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package gcfg 4 | 5 | type textUnmarshaler interface { 6 | UnmarshalText(text []byte) error 7 | } 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/go1_2.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package gcfg 4 | 5 | import ( 6 | "encoding" 7 | ) 8 | 9 | type textUnmarshaler encoding.TextUnmarshaler 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/issues_test.go: -------------------------------------------------------------------------------- 1 | package gcfg 2 | 3 | import ( 4 | "fmt" 5 | "math/big" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | type Config1 struct { 11 | Section struct { 12 | Int int 13 | BigInt big.Int 14 | } 15 | } 16 | 17 | var testsIssue1 = []struct { 18 | cfg string 19 | typename string 20 | }{ 21 | {"[section]\nint=X", "int"}, 22 | {"[section]\nint=", "int"}, 23 | {"[section]\nint=1A", "int"}, 24 | {"[section]\nbigint=X", "big.Int"}, 25 | {"[section]\nbigint=", "big.Int"}, 26 | {"[section]\nbigint=1A", "big.Int"}, 27 | } 28 | 29 | // Value parse error should: 30 | // - include plain type name 31 | // - not include reflect internals 32 | func TestIssue1(t *testing.T) { 33 | for i, tt := range testsIssue1 { 34 | var c Config1 35 | err := ReadStringInto(&c, tt.cfg) 36 | switch { 37 | case err == nil: 38 | t.Errorf("%d fail: got ok; wanted error", i) 39 | case !strings.Contains(err.Error(), tt.typename): 40 | t.Errorf("%d fail: error message doesn't contain type name %q: %v", 41 | i, tt.typename, err) 42 | case strings.Contains(err.Error(), "reflect"): 43 | t.Errorf("%d fail: error message includes reflect internals: %v", 44 | i, err) 45 | default: 46 | t.Logf("%d pass: %v", i, err) 47 | } 48 | } 49 | } 50 | 51 | type confIssue2 struct{ Main struct{ Foo string } } 52 | 53 | var testsIssue2 = []readtest{ 54 | {"[main]\n;\nfoo = bar\n", &confIssue2{struct{ Foo string }{"bar"}}, true}, 55 | {"[main]\r\n;\r\nfoo = bar\r\n", &confIssue2{struct{ Foo string }{"bar"}}, true}, 56 | } 57 | 58 | func TestIssue2(t *testing.T) { 59 | for i, tt := range testsIssue2 { 60 | id := fmt.Sprintf("issue2:%d", i) 61 | testRead(t, id, tt) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/scanner/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package scanner_test 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | import ( 12 | "github.com/asciinema/asciinema/Godeps/_workspace/src/code.google.com/p/gcfg/scanner" 13 | "github.com/asciinema/asciinema/Godeps/_workspace/src/code.google.com/p/gcfg/token" 14 | ) 15 | 16 | func ExampleScanner_Scan() { 17 | // src is the input that we want to tokenize. 18 | src := []byte(`[profile "A"] 19 | color = blue ; Comment`) 20 | 21 | // Initialize the scanner. 22 | var s scanner.Scanner 23 | fset := token.NewFileSet() // positions are relative to fset 24 | file := fset.AddFile("", fset.Base(), len(src)) // register input "file" 25 | s.Init(file, src, nil /* no error handler */, scanner.ScanComments) 26 | 27 | // Repeated calls to Scan yield the token sequence found in the input. 28 | for { 29 | pos, tok, lit := s.Scan() 30 | if tok == token.EOF { 31 | break 32 | } 33 | fmt.Printf("%s\t%q\t%q\n", fset.Position(pos), tok, lit) 34 | } 35 | 36 | // output: 37 | // 1:1 "[" "" 38 | // 1:2 "IDENT" "profile" 39 | // 1:10 "STRING" "\"A\"" 40 | // 1:13 "]" "" 41 | // 1:14 "\n" "" 42 | // 2:1 "IDENT" "color" 43 | // 2:7 "=" "" 44 | // 2:9 "STRING" "blue" 45 | // 2:14 "COMMENT" "; Comment" 46 | } 47 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/testdata/gcfg_test.gcfg: -------------------------------------------------------------------------------- 1 | ; Comment line 2 | [section] 3 | name=value # comment 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/testdata/gcfg_unicode_test.gcfg: -------------------------------------------------------------------------------- 1 | ; Comment line 2 | [甲] 3 | 乙=丙 # comment 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/token/serialize.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package token 6 | 7 | type serializedFile struct { 8 | // fields correspond 1:1 to fields with same (lower-case) name in File 9 | Name string 10 | Base int 11 | Size int 12 | Lines []int 13 | Infos []lineInfo 14 | } 15 | 16 | type serializedFileSet struct { 17 | Base int 18 | Files []serializedFile 19 | } 20 | 21 | // Read calls decode to deserialize a file set into s; s must not be nil. 22 | func (s *FileSet) Read(decode func(interface{}) error) error { 23 | var ss serializedFileSet 24 | if err := decode(&ss); err != nil { 25 | return err 26 | } 27 | 28 | s.mutex.Lock() 29 | s.base = ss.Base 30 | files := make([]*File, len(ss.Files)) 31 | for i := 0; i < len(ss.Files); i++ { 32 | f := &ss.Files[i] 33 | files[i] = &File{s, f.Name, f.Base, f.Size, f.Lines, f.Infos} 34 | } 35 | s.files = files 36 | s.last = nil 37 | s.mutex.Unlock() 38 | 39 | return nil 40 | } 41 | 42 | // Write calls encode to serialize the file set s. 43 | func (s *FileSet) Write(encode func(interface{}) error) error { 44 | var ss serializedFileSet 45 | 46 | s.mutex.Lock() 47 | ss.Base = s.base 48 | files := make([]serializedFile, len(s.files)) 49 | for i, f := range s.files { 50 | files[i] = serializedFile{f.name, f.base, f.size, f.lines, f.infos} 51 | } 52 | ss.Files = files 53 | s.mutex.Unlock() 54 | 55 | return encode(ss) 56 | } 57 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/token/serialize_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package token 6 | 7 | import ( 8 | "bytes" 9 | "encoding/gob" 10 | "fmt" 11 | "testing" 12 | ) 13 | 14 | // equal returns nil if p and q describe the same file set; 15 | // otherwise it returns an error describing the discrepancy. 16 | func equal(p, q *FileSet) error { 17 | if p == q { 18 | // avoid deadlock if p == q 19 | return nil 20 | } 21 | 22 | // not strictly needed for the test 23 | p.mutex.Lock() 24 | q.mutex.Lock() 25 | defer q.mutex.Unlock() 26 | defer p.mutex.Unlock() 27 | 28 | if p.base != q.base { 29 | return fmt.Errorf("different bases: %d != %d", p.base, q.base) 30 | } 31 | 32 | if len(p.files) != len(q.files) { 33 | return fmt.Errorf("different number of files: %d != %d", len(p.files), len(q.files)) 34 | } 35 | 36 | for i, f := range p.files { 37 | g := q.files[i] 38 | if f.set != p { 39 | return fmt.Errorf("wrong fileset for %q", f.name) 40 | } 41 | if g.set != q { 42 | return fmt.Errorf("wrong fileset for %q", g.name) 43 | } 44 | if f.name != g.name { 45 | return fmt.Errorf("different filenames: %q != %q", f.name, g.name) 46 | } 47 | if f.base != g.base { 48 | return fmt.Errorf("different base for %q: %d != %d", f.name, f.base, g.base) 49 | } 50 | if f.size != g.size { 51 | return fmt.Errorf("different size for %q: %d != %d", f.name, f.size, g.size) 52 | } 53 | for j, l := range f.lines { 54 | m := g.lines[j] 55 | if l != m { 56 | return fmt.Errorf("different offsets for %q", f.name) 57 | } 58 | } 59 | for j, l := range f.infos { 60 | m := g.infos[j] 61 | if l.Offset != m.Offset || l.Filename != m.Filename || l.Line != m.Line { 62 | return fmt.Errorf("different infos for %q", f.name) 63 | } 64 | } 65 | } 66 | 67 | // we don't care about .last - it's just a cache 68 | return nil 69 | } 70 | 71 | func checkSerialize(t *testing.T, p *FileSet) { 72 | var buf bytes.Buffer 73 | encode := func(x interface{}) error { 74 | return gob.NewEncoder(&buf).Encode(x) 75 | } 76 | if err := p.Write(encode); err != nil { 77 | t.Errorf("writing fileset failed: %s", err) 78 | return 79 | } 80 | q := NewFileSet() 81 | decode := func(x interface{}) error { 82 | return gob.NewDecoder(&buf).Decode(x) 83 | } 84 | if err := q.Read(decode); err != nil { 85 | t.Errorf("reading fileset failed: %s", err) 86 | return 87 | } 88 | if err := equal(p, q); err != nil { 89 | t.Errorf("filesets not identical: %s", err) 90 | } 91 | } 92 | 93 | func TestSerialization(t *testing.T) { 94 | p := NewFileSet() 95 | checkSerialize(t, p) 96 | // add some files 97 | for i := 0; i < 10; i++ { 98 | f := p.AddFile(fmt.Sprintf("file%d", i), p.Base()+i, i*100) 99 | checkSerialize(t, p) 100 | // add some lines and alternative file infos 101 | line := 1000 102 | for offs := 0; offs < f.Size(); offs += 40 + i { 103 | f.AddLine(offs) 104 | if offs%7 == 0 { 105 | f.AddLineInfo(offs, fmt.Sprintf("file%d", offs), line) 106 | line += 33 107 | } 108 | } 109 | checkSerialize(t, p) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/token/token.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package token defines constants representing the lexical tokens of the gcfg 6 | // configuration syntax and basic operations on tokens (printing, predicates). 7 | // 8 | // Note that the API for the token package may change to accommodate new 9 | // features or implementation changes in gcfg. 10 | // 11 | package token 12 | 13 | import "strconv" 14 | 15 | // Token is the set of lexical tokens of the gcfg configuration syntax. 16 | type Token int 17 | 18 | // The list of tokens. 19 | const ( 20 | // Special tokens 21 | ILLEGAL Token = iota 22 | EOF 23 | COMMENT 24 | 25 | literal_beg 26 | // Identifiers and basic type literals 27 | // (these tokens stand for classes of literals) 28 | IDENT // section-name, variable-name 29 | STRING // "subsection-name", variable value 30 | literal_end 31 | 32 | operator_beg 33 | // Operators and delimiters 34 | ASSIGN // = 35 | LBRACK // [ 36 | RBRACK // ] 37 | EOL // \n 38 | operator_end 39 | ) 40 | 41 | var tokens = [...]string{ 42 | ILLEGAL: "ILLEGAL", 43 | 44 | EOF: "EOF", 45 | COMMENT: "COMMENT", 46 | 47 | IDENT: "IDENT", 48 | STRING: "STRING", 49 | 50 | ASSIGN: "=", 51 | LBRACK: "[", 52 | RBRACK: "]", 53 | EOL: "\n", 54 | } 55 | 56 | // String returns the string corresponding to the token tok. 57 | // For operators and delimiters, the string is the actual token character 58 | // sequence (e.g., for the token ASSIGN, the string is "="). For all other 59 | // tokens the string corresponds to the token constant name (e.g. for the 60 | // token IDENT, the string is "IDENT"). 61 | // 62 | func (tok Token) String() string { 63 | s := "" 64 | if 0 <= tok && tok < Token(len(tokens)) { 65 | s = tokens[tok] 66 | } 67 | if s == "" { 68 | s = "token(" + strconv.Itoa(int(tok)) + ")" 69 | } 70 | return s 71 | } 72 | 73 | // Predicates 74 | 75 | // IsLiteral returns true for tokens corresponding to identifiers 76 | // and basic type literals; it returns false otherwise. 77 | // 78 | func (tok Token) IsLiteral() bool { return literal_beg < tok && tok < literal_end } 79 | 80 | // IsOperator returns true for tokens corresponding to operators and 81 | // delimiters; it returns false otherwise. 82 | // 83 | func (tok Token) IsOperator() bool { return operator_beg < tok && tok < operator_end } 84 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/bool.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // BoolValues defines the name and value mappings for ParseBool. 4 | var BoolValues = map[string]interface{}{ 5 | "true": true, "yes": true, "on": true, "1": true, 6 | "false": false, "no": false, "off": false, "0": false, 7 | } 8 | 9 | var boolParser = func() *EnumParser { 10 | ep := &EnumParser{} 11 | ep.AddVals(BoolValues) 12 | return ep 13 | }() 14 | 15 | // ParseBool parses bool values according to the definitions in BoolValues. 16 | // Parsing is case-insensitive. 17 | func ParseBool(s string) (bool, error) { 18 | v, err := boolParser.Parse(s) 19 | if err != nil { 20 | return false, err 21 | } 22 | return v.(bool), nil 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/doc.go: -------------------------------------------------------------------------------- 1 | // Package types defines helpers for type conversions. 2 | // 3 | // The API for this package is not finalized yet. 4 | package types 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/enum.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | ) 8 | 9 | // EnumParser parses "enum" values; i.e. a predefined set of strings to 10 | // predefined values. 11 | type EnumParser struct { 12 | Type string // type name; if not set, use type of first value added 13 | CaseMatch bool // if true, matching of strings is case-sensitive 14 | // PrefixMatch bool 15 | vals map[string]interface{} 16 | } 17 | 18 | // AddVals adds strings and values to an EnumParser. 19 | func (ep *EnumParser) AddVals(vals map[string]interface{}) { 20 | if ep.vals == nil { 21 | ep.vals = make(map[string]interface{}) 22 | } 23 | for k, v := range vals { 24 | if ep.Type == "" { 25 | ep.Type = reflect.TypeOf(v).Name() 26 | } 27 | if !ep.CaseMatch { 28 | k = strings.ToLower(k) 29 | } 30 | ep.vals[k] = v 31 | } 32 | } 33 | 34 | // Parse parses the string and returns the value or an error. 35 | func (ep EnumParser) Parse(s string) (interface{}, error) { 36 | if !ep.CaseMatch { 37 | s = strings.ToLower(s) 38 | } 39 | v, ok := ep.vals[s] 40 | if !ok { 41 | return false, fmt.Errorf("failed to parse %s %#q", ep.Type, s) 42 | } 43 | return v, nil 44 | } 45 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/enum_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestEnumParserBool(t *testing.T) { 8 | for _, tt := range []struct { 9 | val string 10 | res bool 11 | ok bool 12 | }{ 13 | {val: "tRuE", res: true, ok: true}, 14 | {val: "False", res: false, ok: true}, 15 | {val: "t", ok: false}, 16 | } { 17 | b, err := ParseBool(tt.val) 18 | switch { 19 | case tt.ok && err != nil: 20 | t.Errorf("%q: got error %v, want %v", tt.val, err, tt.res) 21 | case !tt.ok && err == nil: 22 | t.Errorf("%q: got %v, want error", tt.val, b) 23 | case tt.ok && b != tt.res: 24 | t.Errorf("%q: got %v, want %v", tt.val, b, tt.res) 25 | default: 26 | t.Logf("%q: got %v, %v", tt.val, b, err) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/int.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // An IntMode is a mode for parsing integer values, representing a set of 9 | // accepted bases. 10 | type IntMode uint8 11 | 12 | // IntMode values for ParseInt; can be combined using binary or. 13 | const ( 14 | Dec IntMode = 1 << iota 15 | Hex 16 | Oct 17 | ) 18 | 19 | // String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`. 20 | func (m IntMode) String() string { 21 | var modes []string 22 | if m&Dec != 0 { 23 | modes = append(modes, "Dec") 24 | } 25 | if m&Hex != 0 { 26 | modes = append(modes, "Hex") 27 | } 28 | if m&Oct != 0 { 29 | modes = append(modes, "Oct") 30 | } 31 | return "IntMode(" + strings.Join(modes, "|") + ")" 32 | } 33 | 34 | var errIntAmbig = fmt.Errorf("ambiguous integer value; must include '0' prefix") 35 | 36 | func prefix0(val string) bool { 37 | return strings.HasPrefix(val, "0") || strings.HasPrefix(val, "-0") 38 | } 39 | 40 | func prefix0x(val string) bool { 41 | return strings.HasPrefix(val, "0x") || strings.HasPrefix(val, "-0x") 42 | } 43 | 44 | // ParseInt parses val using mode into intptr, which must be a pointer to an 45 | // integer kind type. Non-decimal value require prefix `0` or `0x` in the cases 46 | // when mode permits ambiguity of base; otherwise the prefix can be omitted. 47 | func ParseInt(intptr interface{}, val string, mode IntMode) error { 48 | val = strings.TrimSpace(val) 49 | verb := byte(0) 50 | switch mode { 51 | case Dec: 52 | verb = 'd' 53 | case Dec + Hex: 54 | if prefix0x(val) { 55 | verb = 'v' 56 | } else { 57 | verb = 'd' 58 | } 59 | case Dec + Oct: 60 | if prefix0(val) && !prefix0x(val) { 61 | verb = 'v' 62 | } else { 63 | verb = 'd' 64 | } 65 | case Dec + Hex + Oct: 66 | verb = 'v' 67 | case Hex: 68 | if prefix0x(val) { 69 | verb = 'v' 70 | } else { 71 | verb = 'x' 72 | } 73 | case Oct: 74 | verb = 'o' 75 | case Hex + Oct: 76 | if prefix0(val) { 77 | verb = 'v' 78 | } else { 79 | return errIntAmbig 80 | } 81 | } 82 | if verb == 0 { 83 | panic("unsupported mode") 84 | } 85 | return ScanFully(intptr, val, verb) 86 | } 87 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/int_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func elem(p interface{}) interface{} { 9 | return reflect.ValueOf(p).Elem().Interface() 10 | } 11 | 12 | func TestParseInt(t *testing.T) { 13 | for _, tt := range []struct { 14 | val string 15 | mode IntMode 16 | exp interface{} 17 | ok bool 18 | }{ 19 | {"0", Dec, int(0), true}, 20 | {"10", Dec, int(10), true}, 21 | {"-10", Dec, int(-10), true}, 22 | {"x", Dec, int(0), false}, 23 | {"0xa", Hex, int(0xa), true}, 24 | {"a", Hex, int(0xa), true}, 25 | {"10", Hex, int(0x10), true}, 26 | {"-0xa", Hex, int(-0xa), true}, 27 | {"0x", Hex, int(0x0), true}, // Scanf doesn't require digit behind 0x 28 | {"-0x", Hex, int(0x0), true}, // Scanf doesn't require digit behind 0x 29 | {"-a", Hex, int(-0xa), true}, 30 | {"-10", Hex, int(-0x10), true}, 31 | {"x", Hex, int(0), false}, 32 | {"10", Oct, int(010), true}, 33 | {"010", Oct, int(010), true}, 34 | {"-10", Oct, int(-010), true}, 35 | {"-010", Oct, int(-010), true}, 36 | {"10", Dec | Hex, int(10), true}, 37 | {"010", Dec | Hex, int(10), true}, 38 | {"0x10", Dec | Hex, int(0x10), true}, 39 | {"10", Dec | Oct, int(10), true}, 40 | {"010", Dec | Oct, int(010), true}, 41 | {"0x10", Dec | Oct, int(0), false}, 42 | {"10", Hex | Oct, int(0), false}, // need prefix to distinguish Hex/Oct 43 | {"010", Hex | Oct, int(010), true}, 44 | {"0x10", Hex | Oct, int(0x10), true}, 45 | {"10", Dec | Hex | Oct, int(10), true}, 46 | {"010", Dec | Hex | Oct, int(010), true}, 47 | {"0x10", Dec | Hex | Oct, int(0x10), true}, 48 | } { 49 | typ := reflect.TypeOf(tt.exp) 50 | res := reflect.New(typ).Interface() 51 | err := ParseInt(res, tt.val, tt.mode) 52 | switch { 53 | case tt.ok && err != nil: 54 | t.Errorf("ParseInt(%v, %#v, %v): fail; got error %v, want ok", 55 | typ, tt.val, tt.mode, err) 56 | case !tt.ok && err == nil: 57 | t.Errorf("ParseInt(%v, %#v, %v): fail; got %v, want error", 58 | typ, tt.val, tt.mode, elem(res)) 59 | case tt.ok && !reflect.DeepEqual(elem(res), tt.exp): 60 | t.Errorf("ParseInt(%v, %#v, %v): fail; got %v, want %v", 61 | typ, tt.val, tt.mode, elem(res), tt.exp) 62 | default: 63 | t.Logf("ParseInt(%v, %#v, %s): pass; got %v, error %v", 64 | typ, tt.val, tt.mode, elem(res), err) 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/scan.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "reflect" 7 | ) 8 | 9 | // ScanFully uses fmt.Sscanf with verb to fully scan val into ptr. 10 | func ScanFully(ptr interface{}, val string, verb byte) error { 11 | t := reflect.ValueOf(ptr).Elem().Type() 12 | // attempt to read extra bytes to make sure the value is consumed 13 | var b []byte 14 | n, err := fmt.Sscanf(val, "%"+string(verb)+"%s", ptr, &b) 15 | switch { 16 | case n < 1 || n == 1 && err != io.EOF: 17 | return fmt.Errorf("failed to parse %q as %v: %v", val, t, err) 18 | case n > 1: 19 | return fmt.Errorf("failed to parse %q as %v: extra characters %q", val, t, string(b)) 20 | } 21 | // n == 1 && err == io.EOF 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/gcfg/types/scan_test.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestScanFully(t *testing.T) { 9 | for _, tt := range []struct { 10 | val string 11 | verb byte 12 | res interface{} 13 | ok bool 14 | }{ 15 | {"a", 'v', int(0), false}, 16 | {"0x", 'v', int(0), true}, 17 | {"0x", 'd', int(0), false}, 18 | } { 19 | d := reflect.New(reflect.TypeOf(tt.res)).Interface() 20 | err := ScanFully(d, tt.val, tt.verb) 21 | switch { 22 | case tt.ok && err != nil: 23 | t.Errorf("ScanFully(%T, %q, '%c'): want ok, got error %v", 24 | d, tt.val, tt.verb, err) 25 | case !tt.ok && err == nil: 26 | t.Errorf("ScanFully(%T, %q, '%c'): want error, got %v", 27 | d, tt.val, tt.verb, elem(d)) 28 | case tt.ok && err == nil && !reflect.DeepEqual(tt.res, elem(d)): 29 | t.Errorf("ScanFully(%T, %q, '%c'): want %v, got %v", 30 | d, tt.val, tt.verb, tt.res, elem(d)) 31 | default: 32 | t.Logf("ScanFully(%T, %q, '%c') = %v; *ptr==%v", 33 | d, tt.val, tt.verb, err, elem(d)) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go.crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go.crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/raw.go: -------------------------------------------------------------------------------- 1 | package raw 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // TcSetAttr restores the terminal connected to the given file descriptor to a 9 | // previous state. 10 | func TcSetAttr(fd uintptr, termios *Termios) error { 11 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(termios))); err != 0 { 12 | return err 13 | } 14 | return nil 15 | } 16 | 17 | // TcGetAttr retrieves the current terminal settings and returns it. 18 | func TcGetAttr(fd uintptr) (*Termios, error) { 19 | var termios = &Termios{} 20 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(termios))); err != 0 { 21 | return nil, err 22 | } 23 | return termios, nil 24 | } 25 | 26 | // CfMakeRaw sets the flags stored in the termios structure to a state disabling 27 | // all input and output processing, giving a ``raw I/O path''. 28 | // 29 | // From man cfmakeraw(3) on linux: 30 | // termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); 31 | // termios_p->c_oflag &= ~OPOST; 32 | // termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); 33 | // termios_p->c_cflag &= ~(CSIZE | PARENB); 34 | // termios_p->c_cflag |= CS8; 35 | // 36 | func CfMakeRaw(termios *Termios) { 37 | termios.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) 38 | termios.Oflag &^= syscall.OPOST 39 | termios.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 40 | termios.Cflag &^= (syscall.CSIZE | syscall.PARENB) 41 | termios.Cflag |= syscall.CS8 42 | termios.Cc[syscall.VMIN] = 1 43 | termios.Cc[syscall.VTIME] = 0 44 | } 45 | 46 | // MakeRaw sets the flags stored in the termios structure for the given terminal fd 47 | // to a state disabling all input and output processing, giving a ``raw I/O path''. 48 | // It returns the current terminal's termios struct to allow to revert with TcSetAttr 49 | func MakeRaw(fd uintptr) (*Termios, error) { 50 | old, err := TcGetAttr(fd) 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | new := *old 56 | CfMakeRaw(&new) 57 | 58 | if err := TcSetAttr(fd, &new); err != nil { 59 | return nil, err 60 | } 61 | return old, nil 62 | } 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/raw_test.go: -------------------------------------------------------------------------------- 1 | package raw 2 | 3 | import ( 4 | "syscall" 5 | "testing" 6 | "time" 7 | 8 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/kr/pty" 9 | ) 10 | 11 | func TestCfMakeRaw(t *testing.T) { 12 | termios := &Termios{ 13 | Iflag: 0x2b02, 14 | Oflag: 0x1, 15 | Lflag: 0x5c3, 16 | Cflag: 0x4b00, 17 | Cc: [20]byte{ 18 | 0x4, 0xff, 0xff, 0xff, 19 | 0x17, 0xff, 0x12, 0xff, 20 | 0x3, 0x1c, 0x1a, 0x19, 21 | 0x11, 0x13, 0x16, 0xf, 22 | 0xff, 0xff, 0x14, 0xff, 23 | }, 24 | Ispeed: 0x2580, // (9600) 25 | Ospeed: 0x2580, // (9600) 26 | } 27 | CfMakeRaw(termios) 28 | want := Termios{ 29 | Iflag: 0x2800, 30 | Oflag: 0x0, 31 | Lflag: 0x43, 32 | Cflag: 0x4b00, 33 | Cc: [20]byte{ 34 | 0x4, 0xff, 0xff, 0xff, 35 | 0x17, 0xff, 0x12, 0xff, 36 | 0x3, 0x1c, 0x1a, 0x19, 37 | 0x11, 0x13, 0x16, 0xf, 38 | 0x1, 0x0, 0x14, 0xff, 39 | }, 40 | Ispeed: 0x2580, 41 | Ospeed: 0x2580, 42 | } 43 | if got := *termios; want != got { 44 | t.Fatalf("Unexpected Raw termios.\nGot:\t %#v\nWant:\t %#v\n", got, want) 45 | } 46 | } 47 | 48 | func TestMakeRaw(t *testing.T) { 49 | // Create a PTY pair to play with 50 | master, slave, err := pty.Open() 51 | if err != nil { 52 | t.Fatal(err) 53 | } 54 | defer master.Close() 55 | defer slave.Close() 56 | 57 | // Apply the raw mode on the slave 58 | slaveTermios, err := MakeRaw(slave.Fd()) 59 | if err != nil { 60 | t.Fatal(err) 61 | } 62 | 63 | // Make a copy of the original termios and manually apply cfmakeraw 64 | slaveTermiosOrig := *slaveTermios 65 | CfMakeRaw(&slaveTermiosOrig) 66 | 67 | // Retrieve the new termios on the slave after NakeRaw 68 | slaveTermiosRaw, err := TcGetAttr(slave.Fd()) 69 | if err != nil { 70 | t.Fatal(err) 71 | } 72 | 73 | // Make sure the new termios are the one we want 74 | if slaveTermiosOrig != *slaveTermiosRaw { 75 | t.Fatalf("Unepexpected termios.\nGot:\t %#v\nWant:\t %#v\n", *slaveTermiosRaw, slaveTermiosOrig) 76 | } 77 | 78 | // Simple read/write test on the master/slave pair 79 | want := "hello world!" 80 | go master.WriteString(want) 81 | 82 | var ( 83 | buf = make([]byte, 64) 84 | c = make(chan struct{}) 85 | ) 86 | 87 | // Without raw mode, as there is no \n, read will block forever 88 | go func() { 89 | defer close(c) 90 | n, err := slave.Read(buf) 91 | if err != nil { 92 | t.Fatal(err) 93 | } 94 | buf = buf[:n] 95 | }() 96 | go func() { 97 | time.Sleep(2 * time.Second) 98 | buf = []byte("timeout") 99 | close(c) 100 | }() 101 | <-c 102 | if got := string(buf); got != want { 103 | t.Fatalf("Unexpected result.\nGot: %s\nWant: %s\n", got, want) 104 | } 105 | } 106 | 107 | func BenchmarkCfMakeRaw(b *testing.B) { 108 | t := &Termios{} 109 | for i := 0; i < b.N; i++ { 110 | CfMakeRaw(t) 111 | if t.Cc[syscall.VMIN] != 1 { 112 | b.Fatalf("err") 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/termios_32.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd 2 | 3 | package raw 4 | 5 | // Termios holds the TTY attributes. See man termios(4). 6 | // Tested on linux386, linux/arm, linux/amd64, 7 | // freebsd/386, freebsd/arm, freebsd/amd64. 8 | // See tremios_64.go for darwin. 9 | type Termios struct { 10 | Iflag uint32 11 | Oflag uint32 12 | Cflag uint32 13 | Lflag uint32 14 | Cc [20]byte 15 | Ispeed uint32 16 | Ospeed uint32 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/termios_64.go: -------------------------------------------------------------------------------- 1 | // +build darwin 2 | 3 | package raw 4 | 5 | // Termios holds the TTY attributes. See man termios(4). 6 | // Tested on darwin/386, darwin/amd64. See termios_32.go for others. 7 | type Termios struct { 8 | Iflag uint64 9 | Oflag uint64 10 | Cflag uint64 11 | Lflag uint64 12 | Cc [20]byte 13 | Ispeed uint64 14 | Ospeed uint64 15 | } 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/tioc_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd 2 | 3 | package raw 4 | 5 | import "syscall" 6 | 7 | const ( 8 | getTermios = syscall.TIOCGETA 9 | setTermios = syscall.TIOCSETA 10 | ) 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/creack/termios/raw/tioc_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package raw 4 | 5 | import "syscall" 6 | 7 | const ( 8 | getTermios = syscall.TCGETS 9 | setTermios = syscall.TCSETS 10 | ) 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | # coverage droppings 25 | profile.cov 26 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis CI (http://travis-ci.org/) is a continuous integration 2 | # service for open source projects. This file configures it 3 | # to run unit tests for docopt-go. 4 | 5 | language: go 6 | 7 | go: 8 | - 1.2.2 9 | - 1.3 10 | - tip 11 | 12 | matrix: 13 | fast_finish: true 14 | 15 | before_install: 16 | - go get code.google.com/p/go.tools/cmd/vet 17 | - go get -v github.com/golang/lint/golint 18 | - go get -v code.google.com/p/go.tools/cmd/cover 19 | - go get -v github.com/mattn/goveralls 20 | 21 | install: 22 | - go get -d -v ./... && go build -v ./... 23 | 24 | script: 25 | - go vet -x ./... 26 | - $HOME/gopath/bin/golint . 27 | - go test -v ./... 28 | - go test -covermode=count -coverprofile=profile.cov . 29 | 30 | after_script: 31 | - $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci 32 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Keith Batten 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/README.md: -------------------------------------------------------------------------------- 1 | docopt-go 2 | ========= 3 | 4 | [![Build Status](https://travis-ci.org/docopt/docopt.go.svg?branch=master)](https://travis-ci.org/docopt/docopt.go) 5 | [![Coverage Status](https://coveralls.io/repos/docopt/docopt.go/badge.png)](https://coveralls.io/r/docopt/docopt.go) 6 | [![GoDoc](https://godoc.org/github.com/docopt/docopt.go?status.png)](https://godoc.org/github.com/docopt/docopt.go) 7 | 8 | An implementation of [docopt](http://docopt.org/) in the 9 | [Go](http://golang.org/) programming language. 10 | 11 | **docopt** helps you create *beautiful* command-line interfaces easily: 12 | 13 | ```go 14 | package main 15 | 16 | import ( 17 | "fmt" 18 | "github.com/docopt/docopt-go" 19 | ) 20 | 21 | func main() { 22 | usage := `Naval Fate. 23 | 24 | Usage: 25 | naval_fate ship new ... 26 | naval_fate ship move [--speed=] 27 | naval_fate ship shoot 28 | naval_fate mine (set|remove) [--moored|--drifting] 29 | naval_fate -h | --help 30 | naval_fate --version 31 | 32 | Options: 33 | -h --help Show this screen. 34 | --version Show version. 35 | --speed= Speed in knots [default: 10]. 36 | --moored Moored (anchored) mine. 37 | --drifting Drifting mine.` 38 | 39 | arguments, _ := docopt.Parse(usage, nil, true, "Naval Fate 2.0", false) 40 | fmt.Println(arguments) 41 | } 42 | ``` 43 | 44 | **docopt** parses command-line arguments based on a help message. Don't 45 | write parser code: a good help message already has all the necessary 46 | information in it. 47 | 48 | ## Installation 49 | 50 | ⚠ Use the alias “docopt-go”. To use docopt in your Go code: 51 | 52 | ```go 53 | import "github.com/docopt/docopt-go" 54 | ``` 55 | 56 | To install docopt according to your `$GOPATH`: 57 | 58 | ```console 59 | $ go get github.com/docopt/docopt-go 60 | ``` 61 | 62 | ## API 63 | 64 | ```go 65 | func Parse(doc string, argv []string, help bool, version string, 66 | optionsFirst bool, exit ...bool) (map[string]interface{}, error) 67 | ``` 68 | Parse `argv` based on the command-line interface described in `doc`. 69 | 70 | Given a conventional command-line help message, docopt creates a parser and 71 | processes the arguments. See 72 | https://github.com/docopt/docopt#help-message-format for a description of the 73 | help message format. If `argv` is `nil`, `os.Args[1:]` is used. 74 | 75 | docopt returns a map of option names to the values parsed from `argv`, and an 76 | error or `nil`. 77 | 78 | More documentation for docopt is available at 79 | [GoDoc.org](https://godoc.org/github.com/docopt/docopt.go). 80 | 81 | ## Testing 82 | 83 | All tests from the Python version are implemented and passing 84 | at [Travis CI](https://travis-ci.org/docopt/docopt.go). New 85 | language-agnostic tests have been added 86 | to [test_golang.docopt](test_golang.docopt). 87 | 88 | To run tests for docopt-go, use `go test`. 89 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/example_test.go: -------------------------------------------------------------------------------- 1 | package docopt 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func ExampleParse() { 9 | usage := `Usage: 10 | config_example tcp [] [--force] [--timeout=] 11 | config_example serial [--baud=] [--timeout=] 12 | config_example -h | --help | --version` 13 | // parse the command line `comfig_example tcp 127.0.0.1 --force` 14 | argv := []string{"tcp", "127.0.0.1", "--force"} 15 | arguments, _ := Parse(usage, argv, true, "0.1.1rc", false) 16 | // sort the keys of the arguments map 17 | var keys []string 18 | for k := range arguments { 19 | keys = append(keys, k) 20 | } 21 | sort.Strings(keys) 22 | // print the argument keys and values 23 | for _, k := range keys { 24 | fmt.Printf("%9s %v\n", k, arguments[k]) 25 | } 26 | // output: 27 | // --baud 28 | // --force true 29 | // --help false 30 | // --timeout 31 | // --version false 32 | // -h false 33 | // 127.0.0.1 34 | // 35 | // serial false 36 | // tcp true 37 | } 38 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/arguments/arguments_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Usage: arguments_example [-vqrh] [FILE] ... 10 | arguments_example (--left | --right) CORRECTION FILE 11 | 12 | Process FILE and optionally apply correction to either left-hand side or 13 | right-hand side. 14 | 15 | Arguments: 16 | FILE optional input file 17 | CORRECTION correction angle, needs FILE, --left or --right to be present 18 | 19 | Options: 20 | -h --help 21 | -v verbose mode 22 | -q quiet mode 23 | -r make report 24 | --left use left-hand side 25 | --right use right-hand side` 26 | 27 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 28 | fmt.Println(arguments) 29 | } 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/calculator/calculator_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Not a serious example. 10 | 11 | Usage: 12 | calculator_example ( ( + | - | * | / ) )... 13 | calculator_example [( , )]... 14 | calculator_example (-h | --help) 15 | 16 | Examples: 17 | calculator_example 1 + 2 + 3 + 4 + 5 18 | calculator_example 1 + 2 '*' 3 / 4 - 5 # note quotes around '*' 19 | calculator_example sum 10 , 20 , 30 , 40 20 | 21 | Options: 22 | -h, --help 23 | ` 24 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 25 | fmt.Println(arguments) 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/config_file/config_file_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 7 | "strings" 8 | ) 9 | 10 | func loadJSONConfig() map[string]interface{} { 11 | var result map[string]interface{} 12 | jsonData := []byte(`{"--force": true, "--timeout": "10", "--baud": "9600"}`) 13 | json.Unmarshal(jsonData, &result) 14 | return result 15 | } 16 | 17 | func loadIniConfig() map[string]interface{} { 18 | iniData := ` 19 | [default-arguments] 20 | --force 21 | --baud=19200 22 | =localhost` 23 | // trivial ini parser 24 | // default value for an item is bool: true (for --force) 25 | // otherwise the value is a string 26 | iniParsed := make(map[string]map[string]interface{}) 27 | var section string 28 | for _, line := range strings.Split(iniData, "\n") { 29 | if strings.HasPrefix(line, "[") { 30 | section = line 31 | iniParsed[section] = make(map[string]interface{}) 32 | } else if section != "" { 33 | kv := strings.SplitN(line, "=", 2) 34 | if len(kv) == 1 { 35 | iniParsed[section][kv[0]] = true 36 | } else if len(kv) == 2 { 37 | iniParsed[section][kv[0]] = kv[1] 38 | } 39 | } 40 | } 41 | return iniParsed["[default-arguments]"] 42 | } 43 | 44 | // merge combines two maps. 45 | // truthiness takes priority over falsiness 46 | // mapA takes priority over mapB 47 | func merge(mapA, mapB map[string]interface{}) map[string]interface{} { 48 | result := make(map[string]interface{}) 49 | for k, v := range mapA { 50 | result[k] = v 51 | } 52 | for k, v := range mapB { 53 | if _, ok := result[k]; !ok || result[k] == nil || result[k] == false { 54 | result[k] = v 55 | } 56 | } 57 | return result 58 | } 59 | 60 | func main() { 61 | usage := `Usage: 62 | config_file_example tcp [] [--force] [--timeout=] 63 | config_file_example serial [--baud=] [--timeout=] 64 | config_file_example -h | --help | --version` 65 | 66 | jsonConfig := loadJSONConfig() 67 | iniConfig := loadIniConfig() 68 | arguments, _ := docopt.Parse(usage, nil, true, "0.1.1rc", false) 69 | 70 | // Arguments take priority over INI, INI takes priority over JSON 71 | result := merge(arguments, merge(iniConfig, jsonConfig)) 72 | 73 | fmt.Println("JSON config: ", jsonConfig) 74 | fmt.Println("INI config: ", iniConfig) 75 | fmt.Println("Result: ", result) 76 | } 77 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/counted/counted_example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `Usage: counted_example --help 10 | counted_example -v... 11 | counted_example go [go] 12 | counted_example (--path=)... 13 | counted_example 14 | 15 | Try: counted_example -vvvvvvvvvv 16 | counted_example go go 17 | counted_example --path ./here --path ./there 18 | counted_example this.txt that.txt` 19 | 20 | arguments, _ := docopt.Parse(usage, nil, true, "", false) 21 | fmt.Println(arguments) 22 | } 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/git/branch/git_branch.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `usage: git branch [options] [-r | -a] [--merged= | --no-merged=] 10 | git branch [options] [-l] [-f] [] 11 | git branch [options] [-r] (-d | -D) 12 | git branch [options] (-m | -M) [] 13 | 14 | Generic options: 15 | -h, --help 16 | -v, --verbose show hash and subject, give twice for upstream branch 17 | -t, --track set up tracking mode (see git-pull(1)) 18 | --set-upstream change upstream info 19 | --color= use colored output 20 | -r act on remote-tracking branches 21 | --contains= print only branches that contain the commit 22 | --abbrev= use digits to display SHA-1s 23 | 24 | Specific git-branch actions: 25 | -a list both remote-tracking and local branches 26 | -d delete fully merged branch 27 | -D delete branch (even if not merged) 28 | -m move/rename a branch and its reflog 29 | -M move/rename a branch, even if target exists 30 | -l create the branch's reflog 31 | -f, --force force creation (when already exists) 32 | --no-merged= print only not merged branches 33 | --merged= print only merged branches 34 | ` 35 | 36 | args, _ := docopt.Parse(usage, nil, true, "", false) 37 | fmt.Println(args) 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/docopt/docopt-go/examples/git/checkout/git_checkout.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "github.com/asciinema/asciinema/Godeps/_workspace/src/github.com/docopt/docopt-go" 6 | ) 7 | 8 | func main() { 9 | usage := `usage: git checkout [options] 10 | git checkout [options] -- ... 11 | 12 | options: 13 | -q, --quiet suppress progress reporting 14 | -b create and checkout a new branch 15 | -B create/reset and checkout a branch 16 | -l create reflog for new branch 17 | -t, --track set upstream info for new branch 18 | --orphan 19 | new unparented branch 20 | -2, --ours checkout our version for unmerged files 21 | -3, --theirs checkout their version for unmerged files 22 | -f, --force force checkout (throw away local modifications) 23 | -m, --merge perform a 3-way merge with the new branch 24 | --conflict 14 | 15 | 16 | 17 |

HTTP charset

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

The character encoding of a page can be set using the HTTP header charset declaration.

31 |

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

The only character encoding declaration for this HTML file is in the HTTP header, which sets the encoding to ISO 8859-15.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-001
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 37 |
  • The test is read from a server that supports HTTP.
38 |
39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | HTTP vs UTF-8 BOM 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 |

HTTP vs UTF-8 BOM

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

A character encoding set in the HTTP header has lower precedence than the UTF-8 signature.

31 |

The HTTP header attempts to set the character encoding to ISO 8859-15. The page starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

If the test is unsuccessful, the characters  should appear at the top of the page. These represent the bytes that make up the UTF-8 signature when encountered in the ISO 8859-15 encoding.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-034
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 37 |
  • The test is read from a server that supports HTTP.
38 |
39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HTTP vs meta charset 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 |

HTTP vs meta charset

19 | 20 | 21 |
22 | 23 | 24 |
 
25 | 26 | 27 | 28 | 29 | 30 |
31 |

The HTTP header has a higher precedence than an encoding declaration in a meta charset attribute.

32 |

The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-1.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

33 |
34 |
35 |
HTML5
36 |

the-input-byte-stream-018
Result summary & related tests
Detailed results for this test
Link to spec

37 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 38 |
  • The test is read from a server that supports HTTP.
39 |
40 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HTTP vs meta content 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 |

HTTP vs meta content

19 | 20 | 21 |
22 | 23 | 24 |
 
25 | 26 | 27 | 28 | 29 | 30 |
31 |

The HTTP header has a higher precedence than an encoding declaration in a meta content attribute.

32 |

The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-1.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

33 |
34 |
35 |
HTML5
36 |

the-input-byte-stream-016
Result summary & related tests
Detailed results for this test
Link to spec

37 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 38 |
  • The test is read from a server that supports HTTP.
39 |
40 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | No encoding declaration 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 |

No encoding declaration

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

A page with no encoding information in HTTP, BOM, XML declaration or meta element will be treated as UTF-8.

31 |

The test on this page contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-015
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The test is read from a server that supports HTTP.
37 |
38 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/README: -------------------------------------------------------------------------------- 1 | These test cases come from 2 | http://www.w3.org/International/tests/repository/html5/the-input-byte-stream/results-basics 3 | 4 | Distributed under both the W3C Test Suite License 5 | (http://www.w3.org/Consortium/Legal/2008/04-testsuite-license) 6 | and the W3C 3-clause BSD License 7 | (http://www.w3.org/Consortium/Legal/2008/03-bsd-license). 8 | To contribute to a W3C Test Suite, see the policies and contribution 9 | forms (http://www.w3.org/2004/10/27-testcases). 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattn/asciinema/c382d93fb8105e9e4e4a790d8f70bf702c6c6d4b/Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattn/asciinema/c382d93fb8105e9e4e4a790d8f70bf702c6c6d4b/Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | UTF-8 BOM vs meta charset 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 |

UTF-8 BOM vs meta charset

19 | 20 | 21 |
22 | 23 | 24 |
 
25 | 26 | 27 | 28 | 29 | 30 |
31 |

A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta charset attribute declares a different encoding.

32 |

The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

33 |
34 |
35 |
HTML5
36 |

the-input-byte-stream-038
Result summary & related tests
Detailed results for this test
Link to spec

37 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 38 |
  • The test is read from a server that supports HTTP.
39 |
40 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | UTF-8 BOM vs meta content 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 |

UTF-8 BOM vs meta content

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta content attribute declares a different encoding.

31 |

The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-037
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 37 |
  • The test is read from a server that supports HTTP.
38 |
39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | meta charset attribute 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 |

meta charset attribute

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

The character encoding of the page can be set by a meta element with charset attribute.

31 |

The only character encoding declaration for this HTML file is in the charset attribute of the meta element, which declares the encoding to be ISO 8859-15.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-009
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 37 |
  • The test is read from a server that supports HTTP.
38 |
39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/charset/testdata/meta-content-attribute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | meta content attribute 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 |

meta content attribute

18 | 19 | 20 |
21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | 29 |
30 |

The character encoding of the page can be set by a meta element with http-equiv and content attributes.

31 |

The only character encoding declaration for this HTML file is in the content attribute of the meta element, which declares the encoding to be ISO 8859-15.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

32 |
33 |
34 |
HTML5
35 |

the-input-byte-stream-007
Result summary & related tests
Detailed results for this test
Link to spec

36 |
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • 37 |
  • The test is read from a server that supports HTTP.
38 |
39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/const.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package html 6 | 7 | // Section 12.2.3.2 of the HTML5 specification says "The following elements 8 | // have varying levels of special parsing rules". 9 | // https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements 10 | var isSpecialElementMap = map[string]bool{ 11 | "address": true, 12 | "applet": true, 13 | "area": true, 14 | "article": true, 15 | "aside": true, 16 | "base": true, 17 | "basefont": true, 18 | "bgsound": true, 19 | "blockquote": true, 20 | "body": true, 21 | "br": true, 22 | "button": true, 23 | "caption": true, 24 | "center": true, 25 | "col": true, 26 | "colgroup": true, 27 | "dd": true, 28 | "details": true, 29 | "dir": true, 30 | "div": true, 31 | "dl": true, 32 | "dt": true, 33 | "embed": true, 34 | "fieldset": true, 35 | "figcaption": true, 36 | "figure": true, 37 | "footer": true, 38 | "form": true, 39 | "frame": true, 40 | "frameset": true, 41 | "h1": true, 42 | "h2": true, 43 | "h3": true, 44 | "h4": true, 45 | "h5": true, 46 | "h6": true, 47 | "head": true, 48 | "header": true, 49 | "hgroup": true, 50 | "hr": true, 51 | "html": true, 52 | "iframe": true, 53 | "img": true, 54 | "input": true, 55 | "isindex": true, 56 | "li": true, 57 | "link": true, 58 | "listing": true, 59 | "marquee": true, 60 | "menu": true, 61 | "meta": true, 62 | "nav": true, 63 | "noembed": true, 64 | "noframes": true, 65 | "noscript": true, 66 | "object": true, 67 | "ol": true, 68 | "p": true, 69 | "param": true, 70 | "plaintext": true, 71 | "pre": true, 72 | "script": true, 73 | "section": true, 74 | "select": true, 75 | "source": true, 76 | "style": true, 77 | "summary": true, 78 | "table": true, 79 | "tbody": true, 80 | "td": true, 81 | "template": true, 82 | "textarea": true, 83 | "tfoot": true, 84 | "th": true, 85 | "thead": true, 86 | "title": true, 87 | "tr": true, 88 | "track": true, 89 | "ul": true, 90 | "wbr": true, 91 | "xmp": true, 92 | } 93 | 94 | func isSpecialElement(element *Node) bool { 95 | switch element.Namespace { 96 | case "", "html": 97 | return isSpecialElementMap[element.Data] 98 | case "svg": 99 | return element.Data == "foreignObject" 100 | } 101 | return false 102 | } 103 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/entity_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package html 6 | 7 | import ( 8 | "testing" 9 | "unicode/utf8" 10 | ) 11 | 12 | func TestEntityLength(t *testing.T) { 13 | // We verify that the length of UTF-8 encoding of each value is <= 1 + len(key). 14 | // The +1 comes from the leading "&". This property implies that the length of 15 | // unescaped text is <= the length of escaped text. 16 | for k, v := range entity { 17 | if 1+len(k) < utf8.RuneLen(v) { 18 | t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v)) 19 | } 20 | if len(k) > longestEntityWithoutSemicolon && k[len(k)-1] != ';' { 21 | t.Errorf("entity name %s is %d characters, but longestEntityWithoutSemicolon=%d", k, len(k), longestEntityWithoutSemicolon) 22 | } 23 | } 24 | for k, v := range entity2 { 25 | if 1+len(k) < utf8.RuneLen(v[0])+utf8.RuneLen(v[1]) { 26 | t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v[0]) + string(v[1])) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/escape_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package html 6 | 7 | import "testing" 8 | 9 | type unescapeTest struct { 10 | // A short description of the test case. 11 | desc string 12 | // The HTML text. 13 | html string 14 | // The unescaped text. 15 | unescaped string 16 | } 17 | 18 | var unescapeTests = []unescapeTest{ 19 | // Handle no entities. 20 | { 21 | "copy", 22 | "A\ttext\nstring", 23 | "A\ttext\nstring", 24 | }, 25 | // Handle simple named entities. 26 | { 27 | "simple", 28 | "& > <", 29 | "& > <", 30 | }, 31 | // Handle hitting the end of the string. 32 | { 33 | "stringEnd", 34 | "& &", 35 | "& &", 36 | }, 37 | // Handle entities with two codepoints. 38 | { 39 | "multiCodepoint", 40 | "text ⋛︀ blah", 41 | "text \u22db\ufe00 blah", 42 | }, 43 | // Handle decimal numeric entities. 44 | { 45 | "decimalEntity", 46 | "Delta = Δ ", 47 | "Delta = Δ ", 48 | }, 49 | // Handle hexadecimal numeric entities. 50 | { 51 | "hexadecimalEntity", 52 | "Lambda = λ = λ ", 53 | "Lambda = λ = λ ", 54 | }, 55 | // Handle numeric early termination. 56 | { 57 | "numericEnds", 58 | "&# &#x €43 © = ©f = ©", 59 | "&# &#x €43 © = ©f = ©", 60 | }, 61 | // Handle numeric ISO-8859-1 entity replacements. 62 | { 63 | "numericReplacements", 64 | "Footnote‡", 65 | "Footnote‡", 66 | }, 67 | } 68 | 69 | func TestUnescape(t *testing.T) { 70 | for _, tt := range unescapeTests { 71 | unescaped := UnescapeString(tt.html) 72 | if unescaped != tt.unescaped { 73 | t.Errorf("TestUnescape %s: want %q, got %q", tt.desc, tt.unescaped, unescaped) 74 | } 75 | } 76 | } 77 | 78 | func TestUnescapeEscape(t *testing.T) { 79 | ss := []string{ 80 | ``, 81 | `abc def`, 82 | `a & b`, 83 | `a&b`, 84 | `a & b`, 85 | `"`, 86 | `"`, 87 | `"<&>"`, 88 | `"<&>"`, 89 | `3&5==1 && 0<1, "0<1", a+acute=á`, 90 | `The special characters are: <, >, &, ' and "`, 91 | } 92 | for _, s := range ss { 93 | if got := UnescapeString(EscapeString(s)); got != s { 94 | t.Errorf("got %q want %q", got, s) 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This example demonstrates parsing HTML data and walking the resulting tree. 6 | package html_test 7 | 8 | import ( 9 | "fmt" 10 | "log" 11 | "strings" 12 | 13 | "github.com/asciinema/asciinema/Godeps/_workspace/src/golang.org/x/net/html" 14 | ) 15 | 16 | func ExampleParse() { 17 | s := `

Links:

` 18 | doc, err := html.Parse(strings.NewReader(s)) 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | var f func(*html.Node) 23 | f = func(n *html.Node) { 24 | if n.Type == html.ElementNode && n.Data == "a" { 25 | for _, a := range n.Attr { 26 | if a.Key == "href" { 27 | fmt.Println(a.Val) 28 | break 29 | } 30 | } 31 | } 32 | for c := n.FirstChild; c != nil; c = c.NextSibling { 33 | f(c) 34 | } 35 | } 36 | f(doc) 37 | // Output: 38 | // foo 39 | // /bar/baz 40 | } 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/testdata/webkit/README: -------------------------------------------------------------------------------- 1 | The *.dat files in this directory are copied from The WebKit Open Source 2 | Project, specifically $WEBKITROOT/LayoutTests/html5lib/resources. 3 | WebKit is licensed under a BSD style license. 4 | http://webkit.org/coding/bsd-license.html says: 5 | 6 | Copyright (C) 2009 Apple Inc. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/html/testdata/webkit/adoption01.dat: -------------------------------------------------------------------------------- 1 | #data 2 |

3 | #errors 4 | #document 5 | | 6 | | 7 | | 8 | | 9 | |

10 | | 11 | 12 | #data 13 | 1

23

14 | #errors 15 | #document 16 | | 17 | | 18 | | 19 | | 20 | | "1" 21 | |

22 | | 23 | | "2" 24 | | "3" 25 | 26 | #data 27 | 1 28 | #errors 29 | #document 30 | | 31 | | 32 | | 33 | | 34 | | "1" 35 | |