Skip to content

Commit 8e2e807

Browse files
added default value for query command
1 parent 6860987 commit 8e2e807

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/francescodisalesdev/gitcli/GitCli.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.shell.standard.ShellComponent;
55
import org.springframework.shell.standard.ShellMethod;
66
import com.francescodisalesdev.gitcli.service.GitService;
7+
import org.springframework.shell.standard.ShellOption;
78

89
import java.io.IOException;
910
import java.util.List;
@@ -14,17 +15,18 @@ class GitCli
1415
{
1516

1617
@ShellMethod("search for a git repository")
17-
public void query(String repository,int page)
18+
public void query(String repository,@ShellOption(defaultValue = "1") int page)
1819
{
1920
try
2021
{
22+
2123
GitService gitService = new GitService();
2224
List<String> result = gitService.getResult(repository,page);
2325

2426
if(result==null)
2527
System.out.println("page number must be bigger than 0");
2628
else
27-
gitService.filterPage(result);
29+
gitService.filterPage(repository,result);
2830

2931
}
3032
catch(IOException | ParseException e)

src/main/java/com/francescodisalesdev/gitcli/service/GitService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void getPages(String param) throws IOException
7575

7676
}
7777

78-
public void filterPage(List<String> response)
78+
public void filterPage(String param,List<String> response) throws IOException
7979
{
8080

8181
Iterator responseIterator = response.iterator();
@@ -85,6 +85,9 @@ public void filterPage(List<String> response)
8585
System.out.println(responseIterator.next());
8686
}
8787

88+
System.out.println("total pages for this search:");
89+
this.getPages(param);
90+
8891
}
8992

9093
public void cloneRepository(String repository,String localPath) throws IOException, InterruptedException

0 commit comments

Comments
 (0)