Skip to content

Commit d129006

Browse files
committed
ran gofmt
1 parent ddd2b77 commit d129006

File tree

9 files changed

+38
-47
lines changed

9 files changed

+38
-47
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7-
7+
yast
88
# Test binary, built with `go test -c`
99
*.test
1010

cmd/search.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ and usage of using your command. For example:
2222
Cobra is a CLI library for Go that empowers applications.
2323
This application is a tool to generate the needed files
2424
to quickly create a Cobra application.`,
25-
RunE: Search,
25+
RunE: Search,
2626
}
27+
2728
//Flags for searchCmd
2829
var MovieName string
2930
var SeriesName string
3031
var MovieSet bool
3132
var SeriesSet bool
33+
3234
// For now we will only search for either movie or series one at a time. If both flags set throw error
3335
var BothSet bool
3436

35-
func CheckIfSet(cmd *cobra.Command, args []string) (movieSet, seriesSet, bothSet bool, err error){
37+
func CheckIfSet(cmd *cobra.Command, args []string) (movieSet, seriesSet, bothSet bool, err error) {
3638
if cmd.Flag("movie").Changed {
3739
movieSet = true
3840
}
3941
if cmd.Flag("series").Changed {
4042
seriesSet = true
4143
}
42-
if cmd.Flag("movie").Changed && cmd.Flag("series").Changed {
44+
if cmd.Flag("movie").Changed && cmd.Flag("series").Changed {
4345
bothSet = true
4446
}
4547
if !movieSet && !seriesSet {
@@ -48,7 +50,7 @@ func CheckIfSet(cmd *cobra.Command, args []string) (movieSet, seriesSet, bothSet
4850
return
4951
}
5052

51-
func Search(cmd *cobra.Command, args []string)(error){
53+
func Search(cmd *cobra.Command, args []string) error {
5254
var err error
5355
MovieSet, SeriesSet, BothSet, err = CheckIfSet(cmd, args)
5456
if err != nil {
@@ -63,7 +65,7 @@ func Search(cmd *cobra.Command, args []string)(error){
6365
MovieName = cmd.Flag("movie").Value.String()
6466
fmt.Println("Searching for movie: ", MovieName)
6567
context := scraper.NewQueryContext("movie", MovieName)
66-
Query := core.NewSearchQuery(context)
68+
Query := core.NewSearchQuery(context)
6769
var results []*scraper.Result
6870
if err != nil {
6971
return err
@@ -77,15 +79,14 @@ func Search(cmd *cobra.Command, args []string)(error){
7779
}
7880
return nil
7981
}
80-
8182

8283
// func SearchMovie(movieName string, targetSite url) (error){
83-
84+
8485
// }
8586

8687
func init() {
8788
yastCmd.AddCommand(searchCmd)
88-
89+
8990
// Here you will define your flags and configuration settings.
9091

9192
// Cobra supports Persistent Flags which will work for this command

core/query.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
package core
22

3-
import(
3+
import (
44
"fmt"
55
"github.com/qascade/yast/scraper"
66
)
7+
78
//Keeping this here for now, might be used in building Query Registry
89
type Query interface {
910
Search()
10-
GetResults()
11+
GetResults()
1112
}
1213

13-
type SearchQuery struct{
14+
type SearchQuery struct {
1415
searched bool //To check whether the query has been searched or not
15-
Results []*scraper.Result
16-
Context *scraper.QueryContext
16+
Results []*scraper.Result
17+
Context *scraper.QueryContext
1718
}
1819

19-
20-
func NewSearchQuery(context *scraper.QueryContext) *SearchQuery{
20+
func NewSearchQuery(context *scraper.QueryContext) *SearchQuery {
2121
return &SearchQuery{
2222
searched: false,
23-
Context: context,
23+
Context: context,
2424
}
2525
}
26-
func (q *SearchQuery) Search() (results []*scraper.Result, err error){
26+
func (q *SearchQuery) Search() (results []*scraper.Result, err error) {
2727
scraper := scraper.NewScraper()
2828
results, err = scraper.Scrape(q.Context)
2929
if err != nil {
3030
return nil, err
3131
}
3232
q.Results = results
3333
q.searched = true
34-
return
34+
return
3535
}
36-
func (q *SearchQuery) GetResults() (results []*scraper.Result, err error){
36+
func (q *SearchQuery) GetResults() (results []*scraper.Result, err error) {
3737
if !q.searched {
3838
err = fmt.Errorf("Query has not been searched yet")
3939
return
4040
}
4141
return q.Results, nil
42-
}
42+
}

scraper/result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scraper
2+
23
// Interface that accepts any type of result coming from Scraper
34
type Result interface {
45
}
56

67
type Results []*Result
7-

scraper/scraper.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
package scraper
22

3-
4-
5-
type Scraper struct{
3+
type Scraper struct {
64
//collector colly.NewCollector()
75
}
86

9-
type QueryContext struct{
10-
Type string //movie, series
11-
Query string
7+
type QueryContext struct {
8+
Type string //movie, series
9+
Query string
1210
}
13-
func NewScraper() (*Scraper){
11+
12+
func NewScraper() *Scraper {
1413
return &Scraper{}
1514
}
1615

17-
func NewQueryContext(flagtype string, query string) *QueryContext{
16+
func NewQueryContext(flagtype string, query string) *QueryContext {
1817
return &QueryContext{
19-
Type: flagtype,
18+
Type: flagtype,
2019
Query: query,
2120
}
2221
}
23-
func (s *Scraper) Scrape(context *QueryContext) (results []*Result, err error){
22+
func (s *Scraper) Scrape(context *QueryContext) (results []*Result, err error) {
2423
results = make([]*Result, 0)
2524
err = nil
26-
return
25+
return
2726
}

scraper/target.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
package scraper
2-
3-
func UrlBuilder()

series/series.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package series
1+
package series

tests/listmodel_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
package tests
2-

tui/listmodel.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ func NewListModel(title string, results scraper.Results) ListModel {
8282
if queryItem, ok := result.(movie.Movie); ok {
8383
items = append(items, queryItem)
8484
}
85-
if result.(movie.Movie)
85+
if result.(movie.Movie){
86+
fmt.Println(result)
87+
}
8688
}
8789
delegate := newItemDelegate(delegateKeys)
8890
queryItemList := list.New(items, delegate, 0, 0)
@@ -147,14 +149,6 @@ func (m ListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
147149
case key.Matches(msg, m.keys.toggleHelpMenu):
148150
m.list.SetShowHelp(!m.list.ShowHelp())
149151
return m, nil
150-
151-
// case key.Matches(msg, m.keys.insertItem):
152-
// m.delegateKeys.remove.SetEnabled(true)
153-
// newItem := m.itemGenerator.next()
154-
// insCmd := m.list.InsertItem(0, newItem)
155-
// statusCmd := m.list.NewStatusMessage(statusMessageStyle("Added " + newItem.Title()))
156-
// return m, tea.Batch(insCmd, statusCmd)
157-
// }
158152
}
159153

160154
// This will also call our delegate's update function.
@@ -165,7 +159,7 @@ func (m ListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
165159
return m, tea.Batch(cmds...)
166160
}
167161

168-
func (m ListModel) View() string{
162+
func (m ListModel) View() string {
169163
return appStyle.Render(m.list.View())
170164
}
171165

0 commit comments

Comments
 (0)