Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1715] Add RepoSense CLI Wizard Walkthrough #1950

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
56b693a
Add DES skeleton code
sikai00 Mar 5, 2023
306d157
Add docs
sikai00 Mar 5, 2023
a26facc
Fix import groups in test
sikai00 Mar 5, 2023
534ed26
Fix prompt adding ordering
sikai00 Mar 6, 2023
845abe3
Merge pull request #1 from sikai00/1715-add-skeleton
sikai00 Mar 6, 2023
bcf29ca
Add wizard cli flag to ArgsParser
MarcusTXK Mar 10, 2023
96c24c6
Add view prompt and optional prompt
MarcusTXK Mar 10, 2023
9b39e50
Add repo prompt and update since prompt to be optinal
MarcusTXK Mar 10, 2023
d30c0e8
Fix java.util.NoSuchElementException when running wizard via gradle
MarcusTXK Mar 10, 2023
a713677
Fix import wildcard
MarcusTXK Mar 10, 2023
9a62d24
Refactor optinal prompt and Update prompt field names
MarcusTXK Mar 12, 2023
181a62c
Update optional prompt
MarcusTXK Mar 12, 2023
15577ae
Fix checkstyle error
MarcusTXK Mar 12, 2023
e83fbf0
Update WizardRunnerTest
MarcusTXK Mar 12, 2023
ac8fd12
Update wizard input builder
MarcusTXK Mar 12, 2023
ee5e006
Merge pull request #2 from MarcusTXK/1715-reposense-cli-wizard
sikai00 Mar 13, 2023
f80e0a5
Merge branch 'master' into 1715-reposense-cli-wizard
sikai00 Mar 13, 2023
8b1b7b4
Add UntilPrompt
sikai00 Mar 15, 2023
8cd9366
Merge pull request #3 from sikai00/1715-add-untilprompt
sikai00 Mar 15, 2023
9b47b33
Add documentaion for init
sikai00 Mar 15, 2023
8eb642d
Reorganise file structure
sikai00 Mar 15, 2023
e006376
Rename prompts to prompt
sikai00 Mar 15, 2023
4cadcca
Update cli.md
MarcusTXK Mar 15, 2023
33cee39
Merge pull request #4 from sikai00/1715-add-documentation
MarcusTXK Mar 15, 2023
4b790d8
Merge pull request #5 from sikai00/1715-reorganise
MarcusTXK Mar 15, 2023
d45ecde
Remove redundant translatecommandline method declaration
sikai00 Mar 26, 2023
70297b3
Fix checkstyle
sikai00 Mar 26, 2023
60563c0
Fix addRepos missing whitespace bug, Remove unused methods in inputBu…
MarcusTXK Apr 2, 2023
41e7669
Fix failing WizardRunner tests
MarcusTXK Apr 2, 2023
561f60d
Merge branch 'master' into 1715-reposense-cli-wizard
MarcusTXK Apr 2, 2023
f2815d6
Add docs to using the init flag
sikai00 Apr 3, 2023
9c3f6c2
Update ViewPrompt
MarcusTXK Apr 3, 2023
61e7195
Merge branch '1715-reposense-cli-wizard' of https://github.com/sikai0…
MarcusTXK Apr 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ run {
tasks.compileJava.mustRunAfter(zipReport)
args System.getProperty('args', '').split()
systemProperty "version", getRepoSenseVersion()
standardInput = System.in
}

checkstyle {
Expand Down
13 changes: 13 additions & 0 deletions docs/ug/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ This flag overrides the `Ignore file size limit` field in the CSV config file.

<!-- ------------------------------------------------------------------------------------------------------ -->

### `--init`

**`--init`**: Launches the RepoSense CLI set-up wizard.
* Example: `--init`

<box type="info" seamless>

* The wizard will run through the basic config flags in this order: `--since`, `--until`, `--view`, `--repos`.
* This flag overrides all other flags and thus should be used on its own.
</box>

<!-- ------------------------------------------------------------------------------------------------------ -->

### `--last-modified-date`, `-l`

**`--last-modified-date`**: Specifies that the last modified date of each line of code should be added to `authorship.json`.
Expand Down
3 changes: 3 additions & 0 deletions docs/ug/generatingReports.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ For other types of repositories, external links are disabled.

**To learn how to generate a report using <tooltip content="e.g., generate a report for a different period, for specific file types, for specific authors, etc.">other settings</tooltip>**, head over to the [_**Customizing reports**_](customizingReports.html) section.

**Alternatively**, you may also use the RepoSense CLI set-up wizard, which will take you through a basic configuration of RepoSense through the following command:
* `java -jar RepoSense.jar --init`

<!-- ==================================================================================================== -->

## Generating reports remotely
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/reposense/RepoSense.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
Expand All @@ -23,6 +24,7 @@
import reposense.model.RepoLocation;
import reposense.model.ReportConfiguration;
import reposense.model.ViewCliArguments;
import reposense.model.WizardCliArguments;
import reposense.parser.ArgsParser;
import reposense.parser.AuthorConfigCsvParser;
import reposense.parser.GroupConfigCsvParser;
Expand All @@ -36,6 +38,8 @@
import reposense.system.ReportServer;
import reposense.util.FileUtil;
import reposense.util.TimeUtil;
import reposense.wizard.BasicWizard;
import reposense.wizard.WizardRunner;

/**
* The main RepoSense class.
Expand Down Expand Up @@ -68,6 +72,11 @@ public static void main(String[] args) {
reportConfig = ((ConfigCliArguments) cliArguments).getReportConfiguration();
} else if (cliArguments instanceof LocationsCliArguments) {
configs = getRepoConfigurations((LocationsCliArguments) cliArguments);
} else if (cliArguments instanceof WizardCliArguments) {
WizardRunner wizardRunner = new WizardRunner(new BasicWizard());
wizardRunner.buildInput(new Scanner(System.in));
wizardRunner.run();
return;
} else {
throw new AssertionError("CliArguments's subclass type is unhandled.");
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/reposense/model/WizardCliArguments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package reposense.model;

/**
* Represents command line arguments user supplied when running the program with mandatory field -init.
*/
public class WizardCliArguments extends CliArguments {
}
13 changes: 13 additions & 0 deletions src/main/java/reposense/parser/ArgsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import reposense.model.LocationsCliArguments;
import reposense.model.ReportConfiguration;
import reposense.model.ViewCliArguments;
import reposense.model.WizardCliArguments;
import reposense.system.LogsManager;
import reposense.util.TimeUtil;

Expand Down Expand Up @@ -65,6 +66,8 @@ public class ArgsParser {
public static final String[] CLONING_THREADS_FLAG = new String[] {"--cloning-threads"};
public static final String[] ANALYSIS_THREADS_FLAG = new String[] {"--analysis-threads"};

public static final String[] CLI_WIZARD_FLAGS = new String[] {"--init"};

public static final String[] TEST_MODE_FLAG = new String[] {"--test-mode"};
public static final String[] FRESH_CLONING_FLAG = new String[] {"--fresh-cloning"};

Expand Down Expand Up @@ -239,6 +242,11 @@ private static ArgumentParser getArgumentParser() {
.setDefault(DEFAULT_NUM_ANALYSIS_THREADS)
.help(FeatureControl.SUPPRESS);

parser.addArgument(CLI_WIZARD_FLAGS)
.dest(CLI_WIZARD_FLAGS[0])
.action(Arguments.storeTrue())
.help("Launches the RepoSense Command line wizard to walk through the basic setup.");

// Testing flags
argumentGroup.addArgument(TEST_MODE_FLAG)
.dest(TEST_MODE_FLAG[0])
Expand Down Expand Up @@ -283,6 +291,11 @@ public static CliArguments parse(String[] args) throws HelpScreenException, Pars
boolean shouldIncludeLastModifiedDate = results.get(LAST_MODIFIED_DATE_FLAGS[0]);
boolean shouldPerformShallowCloning = results.get(SHALLOW_CLONING_FLAGS[0]);
boolean shouldFindPreviousAuthors = results.get(FIND_PREVIOUS_AUTHORS_FLAGS[0]);
boolean isWizardCli = results.get(CLI_WIZARD_FLAGS[0]);

if (isWizardCli) {
return new WizardCliArguments();
}

// Report config is ignored if --repos is provided
if (locations == null) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/reposense/wizard/BasicWizard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package reposense.wizard;

import reposense.wizard.prompt.OptionalSincePrompt;
import reposense.wizard.prompt.OptionalUntilPrompt;
import reposense.wizard.prompt.OptionalViewPrompt;
import reposense.wizard.prompt.Prompt;
import reposense.wizard.prompt.RepoPrompt;

/**
* Represents a basic wizard run.
*/
public class BasicWizard extends Wizard {
private static final Prompt[] INITIAL_PROMPTS = new Prompt[] {
new OptionalSincePrompt(),
new OptionalUntilPrompt(),
new OptionalViewPrompt(),
new RepoPrompt()
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it myself and I don't think it makes a lot of sense to put the repo last. I think it should be first since I'm usually thinking of what I want to analyze and then the time interval to analyze rather than the other way around

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, lets change it to be the first.

public BasicWizard() {
super(INITIAL_PROMPTS);
}
}
Loading