Skip to content

Commit

Permalink
chore: removes unnecessary URL parser
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed May 3, 2021
1 parent 9b134c4 commit 5319142
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@ All notable changes to Rover will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- # [x.x.x] - 2021-mm-dd
<!-- # [x.x.x] (unreleased) - 2021-mm-dd
> Important: X breaking changes below, indicated by **❗ BREAKING ❗**
## 🚀 Features
## ❗ BREAKING ❗
## 🐛 Fixes
## 🛠 Maintenance
## 📚 Documentation -->

# [x.x.x] (unreleased) - 2021-mm-dd
> Important: X breaking changes below, indicated by **❗ BREAKING ❗**
## 🚀 Features
## ❗ BREAKING ❗
## 🐛 Fixes
## 🛠 Maintenance

- **Removes unnecessary custom URL parser - [EverlastingBugstopper], [pull/493]**

`structopt` will automatically use the `FromStr` implementation on the `Url` type, so
we have removed the custom parser we were previously using.

[EverlastingBugstopper]: https://github.com/EverlastingBugstopper
[pull/493]: https://github.com/apollographql/rover/pull/493
## 📚 Documentation

# [0.0.10] - 2021-04-27

## 🚀 Features
Expand Down
3 changes: 1 addition & 2 deletions src/command/graph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use url::Url;
use rover_client::{blocking::Client, query::graph::introspect};

use crate::command::RoverStdout;
use crate::utils::parsers::{parse_header, parse_url};
use crate::utils::parsers::parse_header;

#[derive(Debug, Serialize, StructOpt)]
pub struct Introspect {
/// The endpoint of the graph to introspect
#[structopt(parse(try_from_str = parse_url))]
#[serde(skip_serializing)]
pub endpoint: Url,

Expand Down
3 changes: 1 addition & 2 deletions src/command/subgraph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ use url::Url;
use rover_client::{blocking::Client, query::subgraph::introspect};

use crate::command::RoverStdout;
use crate::utils::parsers::{parse_header, parse_url};
use crate::utils::parsers::parse_header;
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
pub struct Introspect {
/// The endpoint of the subgraph to introspect
#[structopt(parse(try_from_str = parse_url))]
#[serde(skip_serializing)]
pub endpoint: Url,

Expand Down
8 changes: 0 additions & 8 deletions src/utils/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use serde::Serialize;
use std::{convert::TryInto, fmt};

use crate::{error::RoverError, Result};
use url::Url;

#[derive(Debug, PartialEq)]
pub enum SchemaSource {
Expand Down Expand Up @@ -126,13 +125,6 @@ pub fn parse_query_percentage_threshold(threshold: &str) -> Result<f64> {
}
}

/// Parse Urls from the command line.
// TODO: @lrlna return error for parse url
pub fn parse_url(url: &str) -> Result<Url> {
let res = Url::parse(url)?;
Ok(res)
}

/// Parses a key:value pair from a string and returns a tuple of key:value.
/// If a full key:value can't be parsed, it will error.
pub fn parse_header(header: &str) -> Result<(String, String)> {
Expand Down

0 comments on commit 5319142

Please sign in to comment.