Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 82c4515

Browse files
authored
update prompts (#409)
<!-- This is an auto-generated comment: release notes by OSS CodeRabbit --> ### Summary by CodeRabbit **New Feature:** - Introduced a `Mobile` struct in `mobile.go` that represents a mobile device with methods to control its operations and battery status. **Documentation:** - Updated instructions in `src/prompts.ts` for providing replacement code suggestions during code reviews, enhancing clarity and precision. > 🎉 Here's to the code that now shines bright, > A mobile struct brought to light. > With power on, off, and usage in sight, > And battery charge to last the night. 📱 > > Instructions updated, clear as day, > For code review suggestions, leading the way. > Celebrate this PR, hip hip hurray! 🥳 <!-- end of auto-generated comment: release notes by OSS CodeRabbit -->
1 parent 9a257da commit 82c4515

File tree

3 files changed

+109
-16
lines changed

3 files changed

+109
-16
lines changed

dist/index.js

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
// Mobile struct represents a mobile device.
9+
type Mobile struct {
10+
Brand string
11+
Model string
12+
IsOn bool
13+
Battery int
14+
LastUsage time.Time
15+
}
16+
17+
// TurnOn turns on the mobile device.
18+
func (m *Mobile) TurnOn() {
19+
m.IsOn = true
20+
m.LastUsage = time.Now()
21+
fmt.Printf("%s %s is now turned on.\n", m.Brand, m.Model)
22+
}
23+
24+
// TurnOff turns off the mobile device.
25+
func (m *Mobile) TurnOff() {
26+
m.IsOn = false
27+
fmt.Printf("%s %s is now turned off.\n", m.Brand, m.Model)
28+
}
29+
30+
// UseMobile simulates the usage of the mobile device.
31+
func (m *Mobile) UseMobile(minutes int) {
32+
if !m.IsOn {
33+
fmt.Println("Please turn on the mobile device first.")
34+
return
35+
}
36+
37+
if m.Battery <= 0 {
38+
fmt.Println("The mobile device is out of battery. Please charge it.")
39+
return
40+
}
41+
42+
m.LastUsage = time.Now()
43+
fmt.Printf("Using %s %s for %d minutes.\n", m.Brand, m.Model, minutes)
44+
45+
// Simulate battery drain
46+
m.Battery -= minutes
47+
if m.Battery < 0 {
48+
m.Battery = 0
49+
}
50+
51+
// Check battery level
52+
if m.Battery == 0 {
53+
m.TurnOff()
54+
fmt.Println("The mobile device is out of battery. Please charge it.")
55+
}
56+
}
57+
58+
// ChargeMobile charges the mobile device.
59+
func (m *Mobile) ChargeMobile(minutes int) {
60+
m.LastUsage = time.Now()
61+
m.Battery += minutes
62+
if m.Battery > 100 {
63+
m.Battery = 100
64+
}
65+
fmt.Printf("Charging %s %s for %d minutes.\n", m.Brand, m.Model, minutes)
66+
}
67+
68+
func main() {
69+
// Create a new mobile device
70+
myMobile := Mobile{
71+
Brand: "Apple",
72+
Model: "iPhone X",
73+
IsOn: false,
74+
Battery: 50,
75+
}
76+
77+
// Turn on the mobile device
78+
myMobile.TurnOn()
79+
80+
// Simulate using the mobile device
81+
myMobile.UseMobile(60)
82+
83+
// Charge the mobile device
84+
myMobile.ChargeMobile(30)
85+
86+
// Simulate using the mobile device again
87+
myMobile.UseMobile(120)
88+
89+
// Turn off the mobile device
90+
myMobile.TurnOff()
91+
}

src/prompts.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,15 @@ format \`<line_number><colon><whitespace>\`.
168168
in the fenced code blocks. These snippets may be added to a different file
169169
(e.g. test cases), or within the same file at locations outside the provided
170170
hunks. Multiple new code snippets are allowed within a single review section.
171-
- If needed, provide replacement code suggestions to fix the issues by using
172-
fenced code blocks with the \`suggestion\` as the language identifier. The
173-
line number range must map exactly to the range (inclusive) that needs to
174-
be replaced within a new hunk. For instance, if 2 lines of code in a hunk
175-
need to be replaced with 15 lines of code, the line number range must be
176-
those exact 2 lines. You must replace all the lines in the range with your
177-
suggestion. Replacement suggestions must be complete, correctly
178-
formatted/indented and without the line number annotations.
171+
- If needed, provide replacement code to fix the issues by using fenced code
172+
blocks with the \`suggestion\` or the \`diff\` as the language identifier/format,
173+
depending on whether the suggestion is a few lines of code (~15 lines) or
174+
a larger diff (> 15 lines) respectively. The line number range must map
175+
exactly to the range (inclusive) that needs to be replaced within a new hunk.
176+
For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of
177+
code, the line number range must be those exact 2 lines. You must replace all
178+
the lines in the range with your suggestion. Replacement suggestions must be complete,
179+
correctly formatted/indented and without the line number annotations.
179180
- If there are no issues found on a line range, you MUST respond with the
180181
text \`LGTM!\` for that line range in the review section.
181182
- Reflect on your comments and line number ranges before sending the final

0 commit comments

Comments
 (0)