Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
ksonnet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ijaz Ahmad
ksonnet
Commits
52af3f6f
Commit
52af3f6f
authored
7 years ago
by
Jessica Yuen
Browse files
Options
Downloads
Patches
Plain Diff
param diff to print colors
Signed-off-by:
Jessica Yuen
<
im.jessicayuen@gmail.com
>
parent
1fdcd06c
No related branches found
No related tags found
No related merge requests found
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vendor/github.com/olekukonko/tablewriter/util.go
+0
-78
0 additions, 78 deletions
vendor/github.com/olekukonko/tablewriter/util.go
vendor/github.com/olekukonko/tablewriter/wrap.go
+0
-99
0 additions, 99 deletions
vendor/github.com/olekukonko/tablewriter/wrap.go
with
0 additions
and
177 deletions
vendor/github.com/olekukonko/tablewriter/util.go
deleted
100644 → 0
+
0
−
78
View file @
1fdcd06c
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Table Writer API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
tablewriter
import
(
"math"
"regexp"
"strings"
"github.com/mattn/go-runewidth"
)
var
ansi
=
regexp
.
MustCompile
(
"
\0
33
\\
[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]"
)
func
DisplayWidth
(
str
string
)
int
{
return
runewidth
.
StringWidth
(
ansi
.
ReplaceAllLiteralString
(
str
,
""
))
}
// Simple Condition for string
// Returns value based on condition
func
ConditionString
(
cond
bool
,
valid
,
inValid
string
)
string
{
if
cond
{
return
valid
}
return
inValid
}
// Format Table Header
// Replace _ , . and spaces
func
Title
(
name
string
)
string
{
origLen
:=
len
(
name
)
name
=
strings
.
Replace
(
name
,
"_"
,
" "
,
-
1
)
name
=
strings
.
Replace
(
name
,
"."
,
" "
,
-
1
)
name
=
strings
.
TrimSpace
(
name
)
if
len
(
name
)
==
0
&&
origLen
>
0
{
// Keep at least one character. This is important to preserve
// empty lines in multi-line headers/footers.
name
=
" "
}
return
strings
.
ToUpper
(
name
)
}
// Pad String
// Attempts to play string in the center
func
Pad
(
s
,
pad
string
,
width
int
)
string
{
gap
:=
width
-
DisplayWidth
(
s
)
if
gap
>
0
{
gapLeft
:=
int
(
math
.
Ceil
(
float64
(
gap
/
2
)))
gapRight
:=
gap
-
gapLeft
return
strings
.
Repeat
(
string
(
pad
),
gapLeft
)
+
s
+
strings
.
Repeat
(
string
(
pad
),
gapRight
)
}
return
s
}
// Pad String Right position
// This would pace string at the left side fo the screen
func
PadRight
(
s
,
pad
string
,
width
int
)
string
{
gap
:=
width
-
DisplayWidth
(
s
)
if
gap
>
0
{
return
s
+
strings
.
Repeat
(
string
(
pad
),
gap
)
}
return
s
}
// Pad String Left position
// This would pace string at the right side fo the screen
func
PadLeft
(
s
,
pad
string
,
width
int
)
string
{
gap
:=
width
-
DisplayWidth
(
s
)
if
gap
>
0
{
return
strings
.
Repeat
(
string
(
pad
),
gap
)
+
s
}
return
s
}
This diff is collapsed.
Click to expand it.
vendor/github.com/olekukonko/tablewriter/wrap.go
deleted
100644 → 0
+
0
−
99
View file @
1fdcd06c
// Copyright 2014 Oleku Konko All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// This module is a Table Writer API for the Go Programming Language.
// The protocols were written in pure Go and works on windows and unix systems
package
tablewriter
import
(
"math"
"strings"
"github.com/mattn/go-runewidth"
)
var
(
nl
=
"
\n
"
sp
=
" "
)
const
defaultPenalty
=
1e5
// Wrap wraps s into a paragraph of lines of length lim, with minimal
// raggedness.
func
WrapString
(
s
string
,
lim
int
)
([]
string
,
int
)
{
words
:=
strings
.
Split
(
strings
.
Replace
(
s
,
nl
,
sp
,
-
1
),
sp
)
var
lines
[]
string
max
:=
0
for
_
,
v
:=
range
words
{
max
=
runewidth
.
StringWidth
(
v
)
if
max
>
lim
{
lim
=
max
}
}
for
_
,
line
:=
range
WrapWords
(
words
,
1
,
lim
,
defaultPenalty
)
{
lines
=
append
(
lines
,
strings
.
Join
(
line
,
sp
))
}
return
lines
,
lim
}
// WrapWords is the low-level line-breaking algorithm, useful if you need more
// control over the details of the text wrapping process. For most uses,
// WrapString will be sufficient and more convenient.
//
// WrapWords splits a list of words into lines with minimal "raggedness",
// treating each rune as one unit, accounting for spc units between adjacent
// words on each line, and attempting to limit lines to lim units. Raggedness
// is the total error over all lines, where error is the square of the
// difference of the length of the line and lim. Too-long lines (which only
// happen when a single word is longer than lim units) have pen penalty units
// added to the error.
func
WrapWords
(
words
[]
string
,
spc
,
lim
,
pen
int
)
[][]
string
{
n
:=
len
(
words
)
length
:=
make
([][]
int
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
length
[
i
]
=
make
([]
int
,
n
)
length
[
i
][
i
]
=
runewidth
.
StringWidth
(
words
[
i
])
for
j
:=
i
+
1
;
j
<
n
;
j
++
{
length
[
i
][
j
]
=
length
[
i
][
j
-
1
]
+
spc
+
runewidth
.
StringWidth
(
words
[
j
])
}
}
nbrk
:=
make
([]
int
,
n
)
cost
:=
make
([]
int
,
n
)
for
i
:=
range
cost
{
cost
[
i
]
=
math
.
MaxInt32
}
for
i
:=
n
-
1
;
i
>=
0
;
i
--
{
if
length
[
i
][
n
-
1
]
<=
lim
{
cost
[
i
]
=
0
nbrk
[
i
]
=
n
}
else
{
for
j
:=
i
+
1
;
j
<
n
;
j
++
{
d
:=
lim
-
length
[
i
][
j
-
1
]
c
:=
d
*
d
+
cost
[
j
]
if
length
[
i
][
j
-
1
]
>
lim
{
c
+=
pen
// too-long lines get a worse penalty
}
if
c
<
cost
[
i
]
{
cost
[
i
]
=
c
nbrk
[
i
]
=
j
}
}
}
}
var
lines
[][]
string
i
:=
0
for
i
<
n
{
lines
=
append
(
lines
,
words
[
i
:
nbrk
[
i
]])
i
=
nbrk
[
i
]
}
return
lines
}
// getLines decomposes a multiline string into a slice of strings.
func
getLines
(
s
string
)
[]
string
{
return
strings
.
Split
(
s
,
nl
)
}
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment