Skip to content

Commit 843a0f6

Browse files
authored
Merge pull request #17 from github/zrdaley/os
Open source the gh-classroom CLI
2 parents bf08033 + d503167 commit 843a0f6

35 files changed

+2801
-10
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/bin
2+
/share/man/man1
3+
/gh-classroom
4+
.envrc
5+
/dist
6+
/site
7+
.github/**/node_modules
8+
/CHANGELOG.md
9+
/script/build
10+
11+
# VS Code
12+
.vscode
13+
14+
# IntelliJ
15+
.idea
16+
17+
# macOS
18+
.DS_Store
19+
20+
# vim
21+
*.swp
22+
23+
vendor/

CODE-OF-CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# For more information, see [docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax)
2+
3+
# This repository is maintained by:
4+
* @github/classroom-reviewers

CONTRIBUTING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Contributing
2+
3+
[fork]: https://github.com/github/gh-classroom/fork
4+
[pr]: https://github.com/github/gh-classroom/compare
5+
[style]: https://github.com/github/gh-classroom/blob/main/.golangci.yaml
6+
[release-docs]: https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license
7+
[good-commit-msg]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
8+
9+
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
10+
11+
Contributions to this project are [released][release-docs] to the public under the [project's open source license](./LICENSE.txt).
12+
13+
Please note that this project is released with a [Contributor Code of Conduct](./CODE-OF-CONDUCT.md). By participating in this project you agree to abide by its terms.
14+
15+
## Prerequisites for running and testing code
16+
17+
These are one time installations required to be able to test your changes locally as part of the pull request (PR) submission process.
18+
19+
1. install Go [through download](https://go.dev/doc/install) | [through Homebrew](https://formulae.brew.sh/formula/go)
20+
1. [install golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
21+
22+
## Submitting a pull request
23+
24+
1. [Fork][fork] and clone the repository
25+
1. Configure and install the dependencies: `go mod tidy`
26+
1. Make sure the tests pass on your machine: `go test -v ./...`
27+
1. Make sure linter passes on your machine: `golangci-lint run`
28+
1. Create a new branch: `git checkout -b my-branch-name`
29+
1. Make your change, add tests, and make sure the tests and linter still pass
30+
1. Push to your fork and [submit a pull request][pr]
31+
1. Please be patient while waiting for your pull request to be reviewed and merged.
32+
33+
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
34+
35+
- Write tests.
36+
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
37+
- Write a [good commit message][good-commit-msg].
38+
39+
## Resources
40+
41+
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
42+
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
43+
- [GitHub Help](https://help.github.com)

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright GitHub
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, 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,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1-
# gh-classroom
2-
GitHub Classroom CLI Extension is a powerful and easy-to-use command line tool that enhances the functionality of the GitHub CLI, specifically tailored for educators using GitHub Classroom.
1+
## GitHub Classroom CLI
32

4-
## Installation
3+
GitHub Classroom CLI Extension is a powerful and easy-to-use command line tool that enhances the functionality of the GitHub CLI, specifically tailored for educators using GitHub Classroom.
54

6-
Install the CLI
5+
## Background
76

7+
- **This project does not currently have a roadmap**
8+
- If you would like to add additional features, please read our [contribution guidelines](./CONTRIBUTING.md)
9+
- To report a security vulnerability, please read our [security guidelines](./SECURITY.md)
10+
11+
## Requirements
12+
13+
### Installation
14+
- Install [Homebrew](https://brew.sh/)
15+
- Install the gh cli
816
```bash
917
brew install gh
1018
```
11-
12-
Install this extension
13-
19+
- Install this extension
1420
```bash
1521
gh extension install github/gh-classroom
1622
```
1723

18-
## Commands
24+
### Commands
1925

2026
For more information and a list of available commands
2127

2228
```bash
2329
gh classroom -h
2430
```
2531

26-
## Contributions
32+
## License
33+
34+
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.
35+
36+
## Maintainers
37+
38+
See [CODEOWNERS](./CODEOWNERS)
39+
40+
## Support
41+
42+
See [SUPPORT](./SUPPORT.md)
43+
44+
## Additional Resources
2745

28-
At this time we are not open to contributions but hang tight as we are working towards that goal!
46+
- [Classroom](https://classroom.github.com)
47+
- [About Extensions](https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions)
48+
- [Extensions Deep Dive](https://github.blog/2023-01-13-new-github-cli-extension-tools/)

SECURITY.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Thanks for helping make GitHub safe for everyone.
2+
3+
# Security
4+
5+
GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
6+
7+
Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we will ensure that your finding gets passed along to the appropriate maintainers for remediation.
8+
9+
## Reporting Security Issues
10+
11+
If you believe you have found a security vulnerability in any GitHub-owned repository, please report it to us through coordinated disclosure.
12+
13+
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
14+
15+
Instead, please send an email to opensource-security[@]github.com.
16+
17+
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
18+
19+
* The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
20+
* Full paths of source file(s) related to the manifestation of the issue
21+
* The location of the affected source code (tag/branch/commit or direct URL)
22+
* Any special configuration required to reproduce the issue
23+
* Step-by-step instructions to reproduce the issue
24+
* Proof-of-concept or exploit code (if possible)
25+
* Impact of the issue, including how an attacker might exploit the issue
26+
27+
This information will help us triage your report more quickly.
28+
29+
## Policy
30+
31+
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/github/site-policy/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)

SUPPORT.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Support
2+
3+
## How to file issues and get help
4+
5+
This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.
6+
7+
For help or questions about using this project, please open an issue.
8+
9+
- **github/gh-classroom** is under active development and maintained by GitHub staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner.
10+
11+
## GitHub Support Policy
12+
13+
Support for this project is limited to the resources listed above.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package accepted
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"strconv"
7+
"strings"
8+
9+
"github.com/cli/cli/pkg/iostreams"
10+
"github.com/cli/cli/v2/pkg/cmdutil"
11+
"github.com/cli/go-gh"
12+
"github.com/cli/go-gh/pkg/browser"
13+
"github.com/cli/go-gh/pkg/tableprinter"
14+
"github.com/cli/go-gh/pkg/term"
15+
"github.com/github/gh-classroom/cmd/gh-classroom/shared"
16+
"github.com/github/gh-classroom/pkg/classroom"
17+
"github.com/spf13/cobra"
18+
)
19+
20+
func NewCmdAcceptedAssignments(f *cmdutil.Factory) *cobra.Command {
21+
var web bool
22+
var assignmentId int
23+
var page int
24+
var perPage int
25+
26+
cmd := &cobra.Command{
27+
Use: "accepted-assignments",
28+
Short: "List your student's accepted assignments",
29+
Run: func(cmd *cobra.Command, args []string) {
30+
term := term.FromEnv()
31+
io := iostreams.System()
32+
cs := io.ColorScheme()
33+
34+
client, err := gh.RESTClient(nil)
35+
var assignment classroom.Assignment
36+
if err != nil {
37+
log.Fatal(err)
38+
}
39+
40+
if assignmentId == 0 {
41+
classroom, err := shared.PromptForClassroom(client)
42+
classroomId := classroom.Id
43+
if err != nil {
44+
log.Fatal(err)
45+
}
46+
47+
assignment, err = shared.PromptForAssignment(client, classroomId)
48+
assignmentId = assignment.Id
49+
if err != nil {
50+
log.Fatal(err)
51+
}
52+
}
53+
54+
if web {
55+
if term.IsTerminalOutput() {
56+
fmt.Fprintln(cmd.ErrOrStderr(), "Opening in your browser.")
57+
}
58+
browser := browser.New("", cmd.OutOrStdout(), cmd.OutOrStderr())
59+
err := browser.Browse(assignment.Url())
60+
if err != nil {
61+
log.Fatal(err)
62+
}
63+
return
64+
}
65+
66+
acceptedAssignments, err := classroom.ListAcceptedAssignments(client, assignmentId, page, perPage)
67+
if err != nil {
68+
log.Fatal(err)
69+
}
70+
71+
fmt.Fprintf(cmd.OutOrStdout(), "Assignment: %v \n", acceptedAssignments.Assignment.Title)
72+
fmt.Fprintf(cmd.OutOrStdout(), "ID: %v \n\n", acceptedAssignments.Assignment.Id)
73+
74+
t := tableprinter.New(cmd.OutOrStdout(), term.IsTerminalOutput(), 14)
75+
t.AddField("ID", tableprinter.WithTruncate(nil))
76+
t.AddField("Submitted", tableprinter.WithTruncate(nil))
77+
t.AddField("Passing", tableprinter.WithTruncate(nil))
78+
t.AddField("Commit Count", tableprinter.WithTruncate(nil))
79+
t.AddField("Grade", tableprinter.WithTruncate(nil))
80+
t.AddField("Feedback Pull Request URL", tableprinter.WithTruncate(nil))
81+
if assignment.IsGroupAssignment() {
82+
t.AddField("Group Members", tableprinter.WithTruncate(nil))
83+
} else {
84+
t.AddField("Student", tableprinter.WithTruncate(nil))
85+
}
86+
t.AddField("Repository", tableprinter.WithTruncate(nil))
87+
t.EndRow()
88+
89+
for _, acceptedAssignment := range acceptedAssignments.AcceptedAssignments {
90+
var students []string
91+
for _, student := range acceptedAssignment.Students {
92+
students = append(students, student.Login)
93+
}
94+
t.AddField(cs.Green(strconv.Itoa(acceptedAssignment.Id)), tableprinter.WithTruncate(nil))
95+
t.AddField(strconv.FormatBool(acceptedAssignment.Submitted), tableprinter.WithTruncate(nil))
96+
t.AddField(strconv.FormatBool(acceptedAssignment.Passing), tableprinter.WithTruncate(nil))
97+
t.AddField(strconv.Itoa(acceptedAssignment.CommitCount), tableprinter.WithTruncate(nil))
98+
t.AddField(acceptedAssignment.Grade, tableprinter.WithTruncate(nil))
99+
t.AddField(acceptedAssignment.FeedbackPullRequestUrl, tableprinter.WithTruncate(nil))
100+
t.AddField(strings.Join(students, ", "), tableprinter.WithTruncate(nil))
101+
t.AddField(acceptedAssignment.RepositoryUrl(), tableprinter.WithTruncate(nil))
102+
t.EndRow()
103+
}
104+
err = t.Render()
105+
if err != nil {
106+
log.Fatal(err)
107+
}
108+
},
109+
}
110+
111+
cmd.Flags().BoolVar(&web, "web", false, "Open the assignment in a browser")
112+
cmd.Flags().IntVarP(&assignmentId, "assignment-id", "a", 0, "ID of the assignment")
113+
cmd.Flags().IntVar(&page, "page", 1, "Page number")
114+
cmd.Flags().IntVar(&perPage, "per-page", 30, "Number of accepted assignments per page")
115+
return cmd
116+
}

0 commit comments

Comments
 (0)